madmin: close http response when returning an error (#6526)

httpRespToErrorResponse() usually reads the http response when
the http error code is not expected to parse the json error
response in the http body, however it was never properly closing
the connection. This PR fixes the behavior.
master
Anis Elleuch 6 years ago committed by Harshavardhana
parent ce1bfa6de8
commit 20378821cf
  1. 1
      pkg/madmin/api-error-response.go
  2. 1
      pkg/madmin/profiling-commands.go

@ -73,6 +73,7 @@ func httpRespToErrorResponse(resp *http.Response) error {
Message: "Failed to parse server response.",
}
}
closeResponse(resp)
return errResp
}

@ -92,7 +92,6 @@ func (adm *AdminClient) DownloadProfilingData() (io.ReadCloser, error) {
}
if resp.StatusCode != http.StatusOK {
closeResponse(resp)
return nil, httpRespToErrorResponse(resp)
}

Loading…
Cancel
Save