1
0
mirror of https://github.com/golang/go synced 2024-11-17 22:54:48 -07:00

net/http: document how Hijack and Request.Context interact

Fixes #22347

Change-Id: If86aa5d54cfd7a7c32d630fb2bf4f47e057dbfb2
Reviewed-on: https://go-review.googlesource.com/115039
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Brad Fitzpatrick 2018-05-29 19:45:34 +00:00
parent 479018150c
commit 39888635ac
2 changed files with 4 additions and 3 deletions

View File

@ -316,7 +316,8 @@ type Request struct {
//
// For incoming server requests, the context is canceled when the
// client's connection closes, the request is canceled (with HTTP/2),
// or when the ServeHTTP method returns.
// the ServeHTTP method returns, or if the Hijack method is
// called on the ResponseWriter.
func (r *Request) Context() context.Context {
if r.ctx != nil {
return r.ctx

View File

@ -187,8 +187,8 @@ type Hijacker interface {
// The returned bufio.Reader may contain unprocessed buffered
// data from the client.
//
// After a call to Hijack, the original Request.Body must
// not be used.
// After a call to Hijack, the original Request.Body must not
// be used, and the Request.Context will be canceled.
Hijack() (net.Conn, *bufio.ReadWriter, error)
}