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: close of Body closes keep-alive connection #5645
Labels
Milestone
Comments
Thanks for the clarification. The change in behaviour was surprising and caused significant performance degradation in some apps I maintain. Can you tell me when the change in behaviour occurred, and ensure the documentation is clarified? It relevant part I find currently reads: "The client must close the response body when finished with it" which is insufficient detail. |
I'm not sure I want to clarify (read: guarantee) the behavior either way. I reserve the right to change the heuristic in the future. (e.g. maybe read-to-EOF if I know EOF is coming "soon", for some definition of "soon", or as a function of whether SPDY is enabled, or whether TCP Fast Open is enabled for that host, etc, etc) But probably I just won't be changing it now. |
I just discovered this issue and was surprised that I've been reading JSON from HTTP responses incorrectly this whole time. I was even more surprised that nowhere in the docs does it say you need to read the entire Body if you want the conn to be reused, though it does say that you need to call Close(). Here's an example that shows how it's so easy to do this wrong, not knowing that some extra whitespace after the JSON object could cause conns not to be reused: http://play.golang.org/p/QMc9Dt0btS If you don't think you should change the behavior, I really think it should at least be documented. |
Okay, I'll document something for Go 1.5. Note that in HTTP/2 this whole issue is moot. Labels changed: added release-go1.5, repo-main, documentation, removed priority-triage. Owner changed to @bradfitz. Status changed to Accepted. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The text was updated successfully, but these errors were encountered: