]> Cypherpunks repositories - gostls13.git/commit
net/http: prevent blocking when draining response body after it has been closed
authorNicholas S. Husin <nsh@golang.org>
Mon, 2 Feb 2026 21:38:01 +0000 (16:38 -0500)
committerNicholas Husin <nsh@golang.org>
Wed, 4 Feb 2026 01:14:44 +0000 (17:14 -0800)
commit1179cfc9b490ce5a8c3adaccea84c79e69f711d7
treea9e6698494a937472e5762118e1c9a91c807d033
parent8572b1cfea49b6108b9fb8ea650c4999ba70d381
net/http: prevent blocking when draining response body after it has been closed

Previously, draining the response body after it has been closed causes
Response.Body.Close to block for longer than it otherwise would. In a
worst-case scenario, this means that we are incurring a 50 ms delay for
each HTTP/1 request that we make.

This CL makes sure that a response body is drained asynchronously and
updates relevant documentations to reflect the current behavior.

For #77370

Change-Id: I2486961bc1ea3d43d727d0aabc7a6ca7dfb166ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/741222
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Nicholas Husin <husin@google.com>
src/net/http/client.go
src/net/http/clientconn_test.go
src/net/http/response.go
src/net/http/transport.go