Skip to content

Commit 11a3f1f

Browse files
committed
ensure closing response body
1 parent ec332fb commit 11a3f1f

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

api/client.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ func (c *Client) Do(req *http.Request) (*http.Response, error) {
6969
if err != nil {
7070
return nil, err
7171
}
72+
defer res.Body.Close()
7273

7374
debug.DumpResponse(res)
7475
return res, nil
@@ -85,6 +86,8 @@ func (c *Client) TokenIsValid() (bool, error) {
8586
if err != nil {
8687
return false, err
8788
}
89+
defer resp.Body.Close()
90+
8891
return resp.StatusCode == http.StatusOK, nil
8992
}
9093

@@ -99,6 +102,8 @@ func (c *Client) IsPingable() error {
99102
if err != nil {
100103
return err
101104
}
105+
defer resp.Body.Close()
106+
102107
if resp.StatusCode != http.StatusOK {
103108
return fmt.Errorf("API returned %s", resp.Status)
104109
}

0 commit comments

Comments
 (0)