diff --git a/src/net/http/request.go b/src/net/http/request.go index 119a015a53..7c4325027c 100644 --- a/src/net/http/request.go +++ b/src/net/http/request.go @@ -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 diff --git a/src/net/http/server.go b/src/net/http/server.go index ac5cadd8d0..2d3486dc66 100644 --- a/src/net/http/server.go +++ b/src/net/http/server.go @@ -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) }