diff --git a/integration-cli/request/request.go b/integration-cli/request/request.go index cb0e39953ed6789577c5df3bdb8c90f6cf804130..be3628b9b2b98a80e28eec2cfbe83bfd71aa9b6e 100644 --- a/integration-cli/request/request.go +++ b/integration-cli/request/request.go @@ -217,13 +217,14 @@ func SockRequestRaw(method, endpoint string, data io.Reader, ct, daemon string, } resp, err := client.Do(req) + if err != nil { + client.Close() + return resp, nil, err + } body := ioutils.NewReadCloserWrapper(resp.Body, func() error { defer resp.Body.Close() return client.Close() }) - if err != nil { - client.Close() - } return resp, body, err }