diff --git a/api/cache.go b/api/cache.go index 79d446ae2..006362504 100644 --- a/api/cache.go +++ b/api/cache.go @@ -84,11 +84,13 @@ func readCache(ttl time.Duration, cacheFile string, req *http.Request) (*http.Re } res, err := http.ReadResponse(bufio.NewReader(f), req) - if res != nil { + if res == nil { res.Body = &readCloser{ Reader: res.Body, Closer: f, } + } else { + f.Close() } return res, err }