]> Cypherpunks repositories - gostls13.git/commit
net/http: do not cancel request context on response body read
authorDamien Neil <dneil@google.com>
Mon, 8 Nov 2021 19:23:27 +0000 (11:23 -0800)
committerDamien Neil <dneil@google.com>
Fri, 12 Nov 2021 20:20:57 +0000 (20:20 +0000)
commit76fbd6167364fb98e3ebe946cfc16b5b84d4240e
tree84805b6ebe5f2e29b725d63ac5b8eaf7b370a2f3
parent95196512b6163dbeff2e7ce5cea65072305905f2
net/http: do not cancel request context on response body read

When sending a Request with a non-context deadline, we create a
context with a timeout. This context is canceled when closing the
response body, and also if a read from the response body returns
an error (including io.EOF).

Cancelling the context in Response.Body.Read interferes with the
HTTP/2 client cleaning up after a request is completed, and is
unnecessary: The user should always close the body, the impact
from not canceling the context is minor (the context timer leaks
until it fires).

Fixes #49366.

Change-Id: Ieaed866116916261d9079f71d8fea7a7b303b8fb
Reviewed-on: https://go-review.googlesource.com/c/go/+/361919
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/net/http/client.go
src/net/http/client_test.go