Ensure that cache file is closed after reading
This commit is contained in:
parent
93c8fc1e98
commit
1d435a3e2e
1 changed files with 3 additions and 1 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue