]> Cypherpunks repositories - gostls13.git/commit
net/http: allow reuse of http.Request objects
authorLuan Santos <cfcluan@gmail.com>
Mon, 11 Sep 2017 15:37:50 +0000 (08:37 -0700)
committerTom Bergan <tombergan@google.com>
Mon, 11 Sep 2017 23:10:06 +0000 (23:10 +0000)
commit78c4dc37097fa98f73de02ffe1709b776a78354d
treedf8fc6f9eed5033714c450cf0f789aebbac1c0ed
parentcf872fae78c48b89814379d7e4a53d1a92b7388f
net/http: allow reuse of http.Request objects

Calling response.Body.Close() early would generarate a race before this.
Since closing would return early before the main code path had a chance
to reset the request canceler. Having a non-nil request canceler at the
start of the next request would cause a "request canceled" error.

Here we simply wait for the eofc channel to be closed before returning
from earlyCloseFn, ensuring that the caller won't be re-using that
Request object before we have a chance to reset the request canceler to
nil.

Fixes #21838

Change-Id: I641815526c6ac63d1816c9b6ad49d73715f7a5cb
Reviewed-on: https://go-review.googlesource.com/62891
Run-TryBot: Tom Bergan <tombergan@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tom Bergan <tombergan@google.com>
src/net/http/transport.go
src/net/http/transport_test.go