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

Always drain body of http.Request might not be required #54

Open
1 task
charconstpointer opened this issue Sep 22, 2022 · 1 comment
Open
1 task

Always drain body of http.Request might not be required #54

charconstpointer opened this issue Sep 22, 2022 · 1 comment

Comments

@charconstpointer
Copy link

I think this might not be the best advice, since it seems like Close() on the *body discards it for you by default

https://github.com/golang/go/blob/9d23975d89e6cc3df4f2156b2ae0df5d2cef16fb/src/net/http/transfer.go#L979

  • always discard body e.g. io.Copy(ioutil.Discard, resp.Body) if you don't use it
    • HTTP client's Transport will not reuse connections unless the body is read to completion and closed

Am I missing something?

@cristaloleg
Copy link
Owner

Yeah, probably it's oudated. I will take a look this weekend.

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

No branches or pull requests

2 participants