mirror of
https://github.com/golang/go
synced 2024-11-02 08:01:26 +00:00
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>
This commit is contained in:
parent
ab2ef4aaa7
commit
193d514131
1 changed files with 2 additions and 5 deletions
|
@ -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,
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue