Skip to content
This repository has been archived by the owner on Apr 20, 2023. It is now read-only.

Fix unclosed response bodies that are not being used #102

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

domenicrosati
Copy link

Using this library, we noticed a memory leak.
We traced it too these response bodies not being able to be closed (becuase they are never passed back)

@mikegleasonjr
Copy link

Friendly ping, can we get a merge on this one 📦

@@ -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

@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)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
4 participants