mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
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
This commit is contained in:
committed by
Shentubot
parent
c2249d6472
commit
a4cc93c7bf
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user