Skip to content

Commit

Permalink
add defered closer calls for the http clients (#705)
Browse files Browse the repository at this point in the history
  • Loading branch information
simskij committed Dec 9, 2020
1 parent 0f06539 commit ea16683
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/registry/auth/auth.go
Expand Up @@ -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{
Expand Down
2 changes: 2 additions & 0 deletions pkg/registry/digest/digest.go
Expand Up @@ -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)
}
Expand Down

0 comments on commit ea16683

Please sign in to comment.