Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure http.Response.Body is closed #363

Merged
merged 1 commit into from Sep 7, 2022
Merged

Conversation

Integralist
Copy link
Collaborator

Fixes #362

@Integralist Integralist added the bug label Sep 7, 2022
@Integralist Integralist requested review from a team and doramatadora and removed request for a team September 7, 2022 16:50
Copy link
Contributor

@doramatadora doramatadora left a comment

Choose a reason for hiding this comment

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

Surprisingly easy to review — 1 change in many places :)

@Integralist Integralist merged commit fece2ad into main Sep 7, 2022
@Integralist Integralist deleted the integralist/close-resp-body branch September 7, 2022 16:55
@joeshaw
Copy link
Member

joeshaw commented Sep 7, 2022

No objection here, but decodeBodyMap already closes the body and it looks like almost all (if not all) requests call that:

defer body.Close()

That makes me wonder if the leak was somewhere else, or if there were particular calls that weren't closing the body.

And it means that the defer body.Close() can probably be dropped from decodeBodyMap and it can take an io.Reader instead of an io.ReadCloser.

@Integralist
Copy link
Collaborator Author

Damn, I didn't realise it was in the decodeBodyMap. My bad. I'll open another PR to fix this up and remove from decodeBodyMap as you've suggested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HTTP client never closes response body
3 participants