From d1ef3ff247d5b2245a5584af592c278fa49c1b89 Mon Sep 17 00:00:00 2001 From: Dmitry Verkhoturov Date: Fri, 14 May 2021 01:04:20 +0200 Subject: [PATCH] fix HTTP response body close in proxy/image.downloadImage --- backend/app/rest/proxy/image.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/app/rest/proxy/image.go b/backend/app/rest/proxy/image.go index 86bd5b74..ec16fb8c 100644 --- a/backend/app/rest/proxy/image.go +++ b/backend/app/rest/proxy/image.go @@ -159,6 +159,7 @@ func (p Image) downloadImage(ctx context.Context, imgURL string) ([]byte, error) if err != nil { return nil, errors.Wrapf(err, "can't download image %s", imgURL) } + defer resp.Body.Close() if resp.StatusCode != http.StatusOK { return nil, errors.Errorf("got unsuccessful response status %d while fetching %s", resp.StatusCode, imgURL) @@ -168,6 +169,5 @@ func (p Image) downloadImage(ctx context.Context, imgURL string) ([]byte, error) if err != nil { return nil, errors.Errorf("unable to read image body") } - _ = resp.Body.Close() return imgData, nil }