]> Cypherpunks repositories - gostls13.git/commitdiff
net/http: correct Client.Do doc about context cancelation
authorManlio Perillo <manlio.perillo@gmail.com>
Thu, 27 May 2021 08:44:57 +0000 (10:44 +0200)
committerDamien Neil <dneil@google.com>
Thu, 27 May 2021 21:41:58 +0000 (21:41 +0000)
The documentation of the Client.Do method and Get function incorrectly
stated that, in case of context cancelation, the returned url.Error
Timeout method returns true.

Update the documentation to correctly match the implementation.
See also CL 200798 that, due to an oversight, corrected only the
documentation of the Client.Get method.

Remove a TODO note added in CL 125575 (net/http: document that Client
methods always return *url.Error), since it is no longer applicable
after CL 200798 (net/http: fix and lock-in Client.Do docs on request
cancelation).

Fixes #46402

Change-Id: Ied2ee971ba22b61777762dbb19f16e08686634ca
Reviewed-on: https://go-review.googlesource.com/c/go/+/323089
Reviewed-by: Damien Neil <dneil@google.com>
Trust: Michael Knyszek <mknyszek@google.com>

src/net/http/client.go

index 03c9155fbdd79e4bd85824de1fd92a2e29c3dcf4..e0cabc9d4cf38143fdf5b406b1e5707a4ea4a5bf 100644 (file)
@@ -433,8 +433,7 @@ func basicAuth(username, password string) string {
 // An error is returned if there were too many redirects or if there
 // was an HTTP protocol error. A non-2xx response doesn't cause an
 // error. Any returned error will be of type *url.Error. The url.Error
-// value's Timeout method will report true if request timed out or was
-// canceled.
+// value's Timeout method will report true if the request timed out.
 //
 // When err is nil, resp always contains a non-nil resp.Body.
 // Caller should close resp.Body when done reading from it.
@@ -589,8 +588,7 @@ func urlErrorOp(method string) string {
 // standard library body types.
 //
 // Any returned error will be of type *url.Error. The url.Error
-// value's Timeout method will report true if request timed out or was
-// canceled.
+// value's Timeout method will report true if the request timed out.
 func (c *Client) Do(req *Request) (*Response, error) {
        return c.do(req)
 }
@@ -729,7 +727,6 @@ func (c *Client) do(req *Request) (retres *Response, reterr error) {
                        reqBodyClosed = true
                        if !deadline.IsZero() && didTimeout() {
                                err = &httpError{
-                                       // TODO: early in cycle: s/Client.Timeout exceeded/timeout or context cancellation/
                                        err:     err.Error() + " (Client.Timeout exceeded while awaiting headers)",
                                        timeout: true,
                                }