diff options
| author | Aaron Jacobs <jacobsa@google.com> | 2015-06-29 10:07:31 +1000 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@golang.org> | 2015-06-30 01:24:15 +0000 |
| commit | 8b4278ffb75e79c277bfa90c5e473bfad9f7c1bd (patch) | |
| tree | 1bc637d810f8d8ff05152165e0e15866d2417b2d /src/net/http/request.go | |
| parent | 1122836b5f07bc9d76ec8667bab34f97e48a75e5 (diff) | |
| download | go-8b4278ffb75e79c277bfa90c5e473bfad9f7c1bd.tar.xz | |
net/http: add a Request.Cancel channel.
This allows for "race free" cancellation, in the sense discussed in
issue #11013: in contrast to Transport.CancelRequest, the cancellation
will not be lost if the user cancels before the request is put into the
transport's internal map.
Fixes #11013.
Change-Id: I0b5e7181231bdd65d900e343f764b4d1d7c422cd
Reviewed-on: https://go-review.googlesource.com/11601
Run-TryBot: David Symonds <dsymonds@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/net/http/request.go')
| -rw-r--r-- | src/net/http/request.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/net/http/request.go b/src/net/http/request.go index 1a9e0fa925..15b73564c6 100644 --- a/src/net/http/request.go +++ b/src/net/http/request.go @@ -224,6 +224,13 @@ type Request struct { // otherwise it leaves the field nil. // This field is ignored by the HTTP client. TLS *tls.ConnectionState + + // Cancel is an optional channel whose closure indicates that the client + // request should be regarded as canceled. Not all implementations of + // RoundTripper may support Cancel. + // + // For server requests, this field is not applicable. + Cancel <-chan struct{} } // ProtoAtLeast reports whether the HTTP protocol used |
