]> Cypherpunks repositories - gostls13.git/commit
net/http: avoid leaking writer goroutines in tests
authorBryan C. Mills <bcmills@google.com>
Wed, 12 Apr 2023 13:58:54 +0000 (13:58 +0000)
committerGopher Robot <gobot@golang.org>
Wed, 12 Apr 2023 16:04:39 +0000 (16:04 +0000)
commitd91d8325308a8ad6943bd46ab3396ae8decd8348
treef46198634cda124d5c103e9fddcda0062b3084a3
parentb7428b7c6de6c7498425fe5374f22b7d3da054f4
net/http: avoid leaking writer goroutines in tests

In TestTransportPrefersResponseOverWriteError and TestMaxBytesHandler,
the server may respond to an incoming request without ever reading the
request body. The client's Do method will return as soon as the
server's response headers are read, but the Transport will remain
active until it notices that the server has closed the connection,
which may be arbitrarily later.

When the server has closed the connection, it will call the Close
method on the request body (if it has such a method). So we can use
that method to find out when the Transport is close enough to done for
the test to complete without interfering too much with other tests.

For #57612.
For #59526.

Change-Id: Iddc7a3b7b09429113ad76ccc1c090ebc9e1835a1
Reviewed-on: https://go-review.googlesource.com/c/go/+/483895
Run-TryBot: Bryan Mills <bcmills@google.com>
Commit-Queue: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
src/net/http/serve_test.go
src/net/http/transport_test.go