From: Tom Bergan Date: Thu, 2 Nov 2017 22:41:10 +0000 (-0700) Subject: net/http: clarify when it is safe to reuse a request X-Git-Tag: go1.10beta1~432 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=3039bff9d07ce05dc9af8c155c6929ae5e53a231;p=gostls13.git net/http: clarify when it is safe to reuse a request The godoc for RoundTrip already specifies when it's ok to reuse a request that contains a body: the caller must wait until RoundTrip calls Close on Request.Body. This CL adds a small clarification: If the request does not have a body, it can be reused as long as the caller does not mutate the Request until RoundTrip fails or the Response.Body is closed. Fixes #19653 Change-Id: I56652a9369978d11650e2e6314104831c2ce5e78 Reviewed-on: https://go-review.googlesource.com/75671 Reviewed-by: Brad Fitzpatrick --- diff --git a/src/net/http/client.go b/src/net/http/client.go index 65e0fa2bc4..6f6024ed4d 100644 --- a/src/net/http/client.go +++ b/src/net/http/client.go @@ -127,7 +127,10 @@ type RoundTripper interface { // authentication, or cookies. // // RoundTrip should not modify the request, except for - // consuming and closing the Request's Body. + // consuming and closing the Request's Body. RoundTrip may + // read fields of the request in a separate goroutine. Callers + // should not mutate the request until the Response's Body has + // been closed. // // RoundTrip must always close the body, including on errors, // but depending on the implementation may do so in a separate