From 193d5141318d65cea310d995258288bd000d734c Mon Sep 17 00:00:00 2001 From: Manlio Perillo Date: Thu, 27 May 2021 10:44:57 +0200 Subject: [PATCH] net/http: correct Client.Do doc about context cancelation 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 Trust: Michael Knyszek --- src/net/http/client.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/net/http/client.go b/src/net/http/client.go index 03c9155fbd..e0cabc9d4c 100644 --- a/src/net/http/client.go +++ b/src/net/http/client.go @@ -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, } -- 2.48.1