Descriptionnet/http: close TCP connection on Response.Body.Close
Previously the HTTP client's (*Response).Body.Close would try
to keep reading until EOF, hoping to reuse the keep-alive HTTP
connection, but the EOF might never come, or it might take a
long time. Now we immediately close the TCP connection if we
haven't seen EOF.
This shifts the burden onto clients to read their whole response
bodies if they want the advantage of reusing TCP connections.
In the future maybe we could decide on heuristics to read some
number of bytes for some max amount of time before forcefully
closing, but I'd rather not for now.
Statistically, touching this code makes things regress, so I
wouldn't be surprised if this introduces new bugs, but all the
tests pass, and I think the code is simpler now too. Maybe.
Please test your HTTP client code before Go 1.1.
Fixes issue 3672
Patch Set 1 #Patch Set 2 : diff -r e39b9fa789ca https://go.googlecode.com/hg/ #Patch Set 3 : diff -r e39b9fa789ca https://go.googlecode.com/hg/ #
Total comments: 10
Patch Set 4 : diff -r 84a41a2c376b https://go.googlecode.com/hg/ #Patch Set 5 : diff -r 91db139d15e5 https://go.googlecode.com/hg/ #
MessagesTotal messages: 6
|