From 20378821cf3a77e34509638a8ba73e0dfbefe1db Mon Sep 17 00:00:00 2001 From: Anis Elleuch Date: Wed, 26 Sep 2018 19:03:35 +0100 Subject: [PATCH] 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. --- pkg/madmin/api-error-response.go | 1 + pkg/madmin/profiling-commands.go | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/madmin/api-error-response.go b/pkg/madmin/api-error-response.go index c85c0bfbb..1cd1ff544 100644 --- a/pkg/madmin/api-error-response.go +++ b/pkg/madmin/api-error-response.go @@ -73,6 +73,7 @@ func httpRespToErrorResponse(resp *http.Response) error { Message: "Failed to parse server response.", } } + closeResponse(resp) return errResp } diff --git a/pkg/madmin/profiling-commands.go b/pkg/madmin/profiling-commands.go index 768376154..6639665af 100644 --- a/pkg/madmin/profiling-commands.go +++ b/pkg/madmin/profiling-commands.go @@ -92,7 +92,6 @@ func (adm *AdminClient) DownloadProfilingData() (io.ReadCloser, error) { } if resp.StatusCode != http.StatusOK { - closeResponse(resp) return nil, httpRespToErrorResponse(resp) }