]> Cypherpunks repositories - gostls13.git/commitdiff
net/http: update request cancelation docs
authorBrad Fitzpatrick <bradfitz@golang.org>
Mon, 13 Aug 2018 16:00:34 +0000 (16:00 +0000)
committerBrad Fitzpatrick <bradfitz@golang.org>
Mon, 13 Aug 2018 18:28:09 +0000 (18:28 +0000)
Fixes #26101

Change-Id: Id4def032b846257d2de992b7561ac90a17e08b91
Reviewed-on: https://go-review.googlesource.com/129155
Reviewed-by: Andrew Bonventre <andybons@golang.org>
src/net/http/client.go
src/net/http/request.go

index fc4a792edd3762634e5ca7e13e198672ec9888d4..8f69a298e3fcf4951a69a60b6ca3d955f8d1308e 100644 (file)
@@ -95,14 +95,12 @@ type Client struct {
        // A Timeout of zero means no timeout.
        //
        // The Client cancels requests to the underlying Transport
-       // using the Request.Cancel mechanism. Requests passed
-       // to Client.Do may still set Request.Cancel; both will
-       // cancel the request.
+       // as if the Request's Context ended.
        //
        // For compatibility, the Client will also use the deprecated
        // CancelRequest method on Transport if found. New
-       // RoundTripper implementations should use Request.Cancel
-       // instead of implementing CancelRequest.
+       // RoundTripper implementations should use the Request's Context
+       // for cancelation instead of implementing CancelRequest.
        Timeout time.Duration
 }
 
index 8cb278ea2c8639e31740553cdbd6e5aad068d911..a40b0a3cb83855d551397f01e5a373d18bec6a06 100644 (file)
@@ -339,6 +339,10 @@ func (r *Request) Context() context.Context {
 
 // WithContext returns a shallow copy of r with its context changed
 // to ctx. The provided ctx must be non-nil.
+//
+// For outgoing client request, the context controls the entire
+// lifetime of a request and its response: obtaining a connection,
+// sending the request, and reading the response headers and body.
 func (r *Request) WithContext(ctx context.Context) *Request {
        if ctx == nil {
                panic("nil context")