aboutsummaryrefslogtreecommitdiffhomepage
path: root/http
diff options
context:
space:
mode:
Diffstat (limited to 'http')
-rw-r--r--http/client/client.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/http/client/client.go b/http/client/client.go
index cba55c4..0ec1603 100644
--- a/http/client/client.go
+++ b/http/client/client.go
@@ -112,6 +112,10 @@ func (c *Client) executeRequest(request *http.Request) (*Response, error) {
client := c.buildClient()
resp, err := client.Do(request)
+ if resp != nil {
+ defer resp.Body.Close()
+ }
+
if err != nil {
if uerr, ok := err.(*url.Error); ok {
switch uerr.Err.(type) {
@@ -135,7 +139,6 @@ func (c *Client) executeRequest(request *http.Request) (*Response, error) {
return nil, err
}
- defer resp.Body.Close()
if resp.ContentLength > maxBodySize {
return nil, fmt.Errorf("client: response too large (%d bytes)", resp.ContentLength)