aboutsummaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
authorManlio Perillo <manlio.perillo@gmail.com>2021-05-27 10:44:57 +0200
committerDamien Neil <dneil@google.com>2021-05-27 21:41:58 +0000
commit193d5141318d65cea310d995258288bd000d734c (patch)
tree7e7e31aa1602c5fb3469e0ffa94944056896b482 /src/net
parentab2ef4aaa77dff91cd98ded88aeba0bf5b5b2e80 (diff)
downloadgo-193d5141318d65cea310d995258288bd000d734c.tar.gz
go-193d5141318d65cea310d995258288bd000d734c.zip
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 <dneil@google.com> Trust: Michael Knyszek <mknyszek@google.com>
Diffstat (limited to 'src/net')
-rw-r--r--src/net/http/client.go7
1 files 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,
}