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

net/http: documentation unclear about when request body is closed #33244

Closed
gbbr opened this issue Jul 23, 2019 · 1 comment
Closed

net/http: documentation unclear about when request body is closed #33244

gbbr opened this issue Jul 23, 2019 · 1 comment

Comments

@gbbr
Copy link
Member

gbbr commented Jul 23, 2019

It is currently possible for a request body to be read, even after http.Client.Do returns. This can be a source of potential race conditions. It is currently unclear in the documentation that this can happen. To the contrary, the documentation is hinting at the fact that the request body will be closed after the function returns, at least to my understanding. To illustrate, the attached playground example reproduces the problem, when compiled with the -race flag:

https://play.golang.org/p/Z0t0QEawcev

The purpose of this issue is to clarify whether:

  • This is a bug?
  • Documentation can be improved?

Useful links:

@gbbr
Copy link
Member Author

gbbr commented Jul 24, 2019

Closing this. I'd say the http.RoundTripper + http.Client.Do documentations pretty much hint at this, even if unexpected. I'm not sure if this can be further improved in any way.

@gbbr gbbr closed this as completed Jul 24, 2019
@golang golang locked and limited conversation to collaborators Jul 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants