From fc340ec9667b9adb3df1ff6599b7bbc64b6838b7 Mon Sep 17 00:00:00 2001 From: Sam Alba Date: Mon, 3 Jun 2013 12:14:57 -0700 Subject: [PATCH] Fixed missing Body.Close when doing some HTTP requests. It should improve some request issues. --- docs/registry.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/registry.go b/docs/registry.go index 36b01d64..d9f53ee9 100644 --- a/docs/registry.go +++ b/docs/registry.go @@ -64,6 +64,9 @@ func (r *Registry) LookupRemoteImage(imgId, registry string, authConfig *auth.Au } req.SetBasicAuth(authConfig.Username, authConfig.Password) res, err := rt.RoundTrip(req) + if err == nil { + defer res.Body.Close() + } return err == nil && res.StatusCode == 307 } @@ -152,7 +155,9 @@ func (r *Registry) GetRemoteTags(registries []string, repository string, token [ } req.Header.Set("Authorization", "Token "+strings.Join(token, ", ")) res, err := r.client.Do(req) - defer res.Body.Close() + if err == nil { + defer res.Body.Close() + } utils.Debugf("Got status code %d from %s", res.StatusCode, endpoint) if err != nil || (res.StatusCode != 200 && res.StatusCode != 404) { continue