Skip to content

Commit cfaee19

Browse files
committed
net/http: document behaviour of cancellation on writable response bodies
1 parent 7765576 commit cfaee19

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/net/http/request.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,10 @@ func (r *Request) Context() context.Context {
345345
// For outgoing client request, the context controls the entire
346346
// lifetime of a request and its response: obtaining a connection,
347347
// sending the request, and reading the response headers and body.
348+
//
349+
// The only exception is for responses with writable bodies where
350+
// the cancellation of the context will not close the body.
351+
// See Response.Body for instances where the body is writable.
348352
func (r *Request) WithContext(ctx context.Context) *Request {
349353
if ctx == nil {
350354
panic("nil context")

0 commit comments

Comments
 (0)