aboutsummaryrefslogtreecommitdiff
path: root/src/net/http/clientconn_test.go
diff options
context:
space:
mode:
authorNicholas S. Husin <nsh@golang.org>2026-02-02 16:38:01 -0500
committerNicholas Husin <nsh@golang.org>2026-02-03 17:14:44 -0800
commit1179cfc9b490ce5a8c3adaccea84c79e69f711d7 (patch)
treea9e6698494a937472e5762118e1c9a91c807d033 /src/net/http/clientconn_test.go
parent8572b1cfea49b6108b9fb8ea650c4999ba70d381 (diff)
downloadgo-1179cfc9b490ce5a8c3adaccea84c79e69f711d7.tar.xz
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>
Diffstat (limited to 'src/net/http/clientconn_test.go')
-rw-r--r--src/net/http/clientconn_test.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/net/http/clientconn_test.go b/src/net/http/clientconn_test.go
index 03d47939aa..1027d75fed 100644
--- a/src/net/http/clientconn_test.go
+++ b/src/net/http/clientconn_test.go
@@ -13,6 +13,7 @@ import (
"sync/atomic"
"testing"
"testing/synctest"
+ "time"
)
func TestTransportNewClientConnRoundTrip(t *testing.T) { run(t, testTransportNewClientConnRoundTrip) }
@@ -283,6 +284,9 @@ func TestClientConnReserveAndConsume(t *testing.T) {
}
test.consume(t, cc, mode)
+ if mode == http1Mode || mode == https1Mode {
+ time.Sleep(http.MaxPostCloseReadTime)
+ }
synctest.Wait()
// State hook should be called, either to report the