]> Cypherpunks repositories - gostls13.git/commitdiff
net/http: document when request bodies are closed in more places
authorDamien Neil <dneil@google.com>
Thu, 24 Aug 2023 17:58:51 +0000 (10:58 -0700)
committerGopher Robot <gobot@golang.org>
Fri, 25 Aug 2023 17:18:36 +0000 (17:18 +0000)
It isn't obvious that request bodies can be closed asynchronously,
and it's easy to overlook the documentation of this fact in
RoundTripper, which is a fairly low-level interface.

Change-Id: I3b825c505418af7e1d3f6ed58f3704e55cf16901
Reviewed-on: https://go-review.googlesource.com/c/go/+/523036
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Damien Neil <dneil@google.com>

src/net/http/client.go
src/net/http/request.go

index 2cab53a585ab770d5cb502b7b510819f5293b37c..5478690ecf874d9bd0220ced48707e02e3cb7cba 100644 (file)
@@ -566,7 +566,8 @@ func urlErrorOp(method string) string {
 // connection to the server for a subsequent "keep-alive" request.
 //
 // The request Body, if non-nil, will be closed by the underlying
-// Transport, even on errors.
+// Transport, even on errors. The Body may be closed asynchronously after
+// Do returns.
 //
 // On error, any Response can be ignored. A non-nil Response with a
 // non-nil error only occurs when CheckRedirect fails, and even then
index 0fb73c12b55c54b8ad4b96b18621d18ccce99f81..12039c9ae2388bc7c979127886f8750707763445 100644 (file)
@@ -845,8 +845,9 @@ func NewRequest(method, url string, body io.Reader) (*Request, error) {
 // optional body.
 //
 // If the provided body is also an io.Closer, the returned
-// Request.Body is set to body and will be closed by the Client
-// methods Do, Post, and PostForm, and Transport.RoundTrip.
+// Request.Body is set to body and will be closed (possibly
+// asynchronously) by the Client methods Do, Post, and PostForm,
+// and Transport.RoundTrip.
 //
 // NewRequestWithContext returns a Request suitable for use with
 // Client.Do or Transport.RoundTrip. To create a request for use with