diff --git a/client.go b/client.go index 3ab93820..867af704 100644 --- a/client.go +++ b/client.go @@ -590,6 +590,8 @@ func (c *Client) checkResponse(resp *http.Response, err error) (*http.Response, func (c *Client) getErrorFromResponse(resp *http.Response) APIError { // check whether the error response is declared as JSON if !strings.HasPrefix(resp.Header.Get("Content-Type"), "application/json") { + defer resp.Body.Close() + aerr := APIError{ StatusCode: resp.StatusCode, message: fmt.Sprintf("HTTP response with status code %d does not contain Content-Type: application/json", resp.StatusCode),