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 <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
//
// But that's okay, since what we're really testing is that
// the remote side hung up on us before we wrote too much.
- _, _ = cst.c.Do(req)
+ resp, err := cst.c.Do(req)
+ if err == nil {
+ resp.Body.Close()
+ }
if atomic.LoadInt64(nWritten) > limit*100 {
t.Errorf("handler restricted the request body to %d bytes, but client managed to write %d",