summaryrefslogtreecommitdiffhomepage
path: root/runsc/test/testutil
diff options
context:
space:
mode:
authorKevin Krakauer <krakauer@google.com>2018-11-01 10:35:04 -0700
committerShentubot <shentubot@google.com>2018-11-01 10:35:53 -0700
commita4cc93c7bf40679e62a2b0eaa2419a4a9536cc14 (patch)
treed96c621a3ac9bf79af962a4dbd5422c6de2f09e6 /runsc/test/testutil
parentc2249d6472342b9cbb641d726e21bba4215ae4e0 (diff)
Close http.Response.Body after Get request.
From https://golang.org/pkg/net/http/#Get: "When err is nil, resp always contains a non-nil resp.Body. Caller should close resp.Body when done reading from it." PiperOrigin-RevId: 219658052 Change-Id: I556e88ac4f2c90cd36ab16cd3163d1a52afc32b7
Diffstat (limited to 'runsc/test/testutil')
-rw-r--r--runsc/test/testutil/testutil.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/runsc/test/testutil/testutil.go b/runsc/test/testutil/testutil.go
index 1b5a02c0f..fd558e2d5 100644
--- a/runsc/test/testutil/testutil.go
+++ b/runsc/test/testutil/testutil.go
@@ -230,8 +230,12 @@ func Poll(cb func() error, timeout time.Duration) error {
// WaitForHTTP tries GET requests on a port until the call succeeds or timeout.
func WaitForHTTP(port int, timeout time.Duration) error {
cb := func() error {
- _, err := http.Get(fmt.Sprintf("http://localhost:%d/", port))
- return err
+ resp, err := http.Get(fmt.Sprintf("http://localhost:%d/", port))
+ if err != nil {
+ return err
+ }
+ resp.Body.Close()
+ return nil
}
return Poll(cb, timeout)
}