Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Apr 20, 2023. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions 4 httpcache.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,15 @@ func (t *Transport) RoundTrip(req *http.Request) (resp *http.Response, err error
for _, header := range endToEndHeaders {
cachedResp.Header[header] = resp.Header[header]
}
resp.Body.Close()
Copy link
Copy Markdown

@CAFxX CAFxX Feb 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be ideal to do

io.Copy(io.Discard, resp.Body)
resp.Body.Close()

so that the HTTP connection can also be reused

(same below)

resp = cachedResp
} else if (err != nil || (cachedResp != nil && resp.StatusCode >= 500)) &&
req.Method == "GET" && canStaleOnError(cachedResp.Header, req.Header) {
// In case of transport failure and stale-if-error activated, returns cached content
// when available
if resp != nil && resp.Body != nil {
resp.Body.Close()
}
return cachedResp, nil
} else {
if err != nil || resp.StatusCode != http.StatusOK {
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.