Skip to content

Commit 8bfe839

Browse files
committed
net/http: close response body in TestRequestBodyLimit
Failing to close the response body before returning leaks the in-progress request past the test lifetime. Fixes #60264 Change-Id: Ic327d9f8e02e87ed656324aaa042f833d9ea18ca Reviewed-on: https://go-review.googlesource.com/c/go/+/501309 Run-TryBot: Damien Neil <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Bryan Mills <[email protected]>
1 parent 72b08db commit 8bfe839

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/net/http/serve_test.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -3012,7 +3012,10 @@ func testRequestBodyLimit(t *testing.T, mode testMode) {
30123012
//
30133013
// But that's okay, since what we're really testing is that
30143014
// the remote side hung up on us before we wrote too much.
3015-
_, _ = cst.c.Do(req)
3015+
resp, err := cst.c.Do(req)
3016+
if err == nil {
3017+
resp.Body.Close()
3018+
}
30163019

30173020
if atomic.LoadInt64(nWritten) > limit*100 {
30183021
t.Errorf("handler restricted the request body to %d bytes, but client managed to write %d",

0 commit comments

Comments
 (0)