]> Cypherpunks repositories - gostls13.git/commit
http: fix transport bug with zero-length bodies
authorBrad Fitzpatrick <bradfitz@golang.org>
Wed, 11 May 2011 19:11:32 +0000 (12:11 -0700)
committerBrad Fitzpatrick <bradfitz@golang.org>
Wed, 11 May 2011 19:11:32 +0000 (12:11 -0700)
commitca83cd2c2f75075b6b7b8b06d25dbe50a3659e9f
tree6cd43ca0351cbf9118e46e9ddf5852a05e10a932
parent51e6aa1e885fc159343f980a0a709f660e27c2fa
http: fix transport bug with zero-length bodies

An optimization in Transport which re-uses TCP
connections early in the case where there is
no response body interacted poorly with
ErrBodyReadAfterClose.  Upon recycling the TCP
connection early we would Close the Response.Body
(in case the user forgot to), but in the case
of a zero-lengthed body, the user's handler might
not have run yet.

This CL makes sure the Transport doesn't try
to Close requests when we're about to immediately
re-use the TCP connection.

This also includes additional tests I wrote
while debugging.

R=rsc, bradfitzgoog
CC=golang-dev
https://golang.org/cl/4529050
src/pkg/http/serve_test.go
src/pkg/http/transport.go
src/pkg/io/multi_test.go
src/pkg/mime/multipart/multipart_test.go