From ea16683c46bf563acb3980fd510a22667c3c3d83 Mon Sep 17 00:00:00 2001 From: Simon Aronsson Date: Wed, 9 Dec 2020 16:18:07 +0100 Subject: [PATCH] add defered closer calls for the http clients (#705) --- pkg/registry/auth/auth.go | 2 +- pkg/registry/digest/digest.go | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/registry/auth/auth.go b/pkg/registry/auth/auth.go index 56f64a2..1596aca 100644 --- a/pkg/registry/auth/auth.go +++ b/pkg/registry/auth/auth.go @@ -37,7 +37,7 @@ func GetToken(container types.Container, registryAuth string) (string, error) { if res, err = client.Do(req); err != nil { return "", err } - + defer res.Body.Close() v := res.Header.Get(ChallengeHeader) logrus.WithFields(logrus.Fields{ diff --git a/pkg/registry/digest/digest.go b/pkg/registry/digest/digest.go index aae8dfb..389f059 100644 --- a/pkg/registry/digest/digest.go +++ b/pkg/registry/digest/digest.go @@ -91,6 +91,8 @@ func GetDigest(url string, token string) (string, error) { if err != nil { return "", err } + defer res.Body.Close() + if res.StatusCode != 200 { return "", fmt.Errorf("registry responded to head request with %d", res.StatusCode) }