mirror of
https://github.com/golang/go
synced 2024-11-07 13:46:19 -07:00
net/http: update request cancelation docs
Fixes #26101 Change-Id: Id4def032b846257d2de992b7561ac90a17e08b91 Reviewed-on: https://go-review.googlesource.com/129155 Reviewed-by: Andrew Bonventre <andybons@golang.org>
This commit is contained in:
parent
015873c153
commit
7a6fc1f30b
@ -95,14 +95,12 @@ type Client struct {
|
|||||||
// A Timeout of zero means no timeout.
|
// A Timeout of zero means no timeout.
|
||||||
//
|
//
|
||||||
// The Client cancels requests to the underlying Transport
|
// The Client cancels requests to the underlying Transport
|
||||||
// using the Request.Cancel mechanism. Requests passed
|
// as if the Request's Context ended.
|
||||||
// to Client.Do may still set Request.Cancel; both will
|
|
||||||
// cancel the request.
|
|
||||||
//
|
//
|
||||||
// For compatibility, the Client will also use the deprecated
|
// For compatibility, the Client will also use the deprecated
|
||||||
// CancelRequest method on Transport if found. New
|
// CancelRequest method on Transport if found. New
|
||||||
// RoundTripper implementations should use Request.Cancel
|
// RoundTripper implementations should use the Request's Context
|
||||||
// instead of implementing CancelRequest.
|
// for cancelation instead of implementing CancelRequest.
|
||||||
Timeout time.Duration
|
Timeout time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -339,6 +339,10 @@ func (r *Request) Context() context.Context {
|
|||||||
|
|
||||||
// WithContext returns a shallow copy of r with its context changed
|
// WithContext returns a shallow copy of r with its context changed
|
||||||
// to ctx. The provided ctx must be non-nil.
|
// 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 {
|
func (r *Request) WithContext(ctx context.Context) *Request {
|
||||||
if ctx == nil {
|
if ctx == nil {
|
||||||
panic("nil context")
|
panic("nil context")
|
||||||
|
Loading…
Reference in New Issue
Block a user