add a response body close

Signed-off-by: Allen Sun <shlallen1990@gmail.com>
This commit is contained in:
Allen Sun 2017-09-21 20:11:22 +08:00
parent b6a0fb137e
commit c6d55954e0

View File

@ -51,10 +51,10 @@ func (r dockerFetcher) Fetch(ctx context.Context, desc ocispec.Descriptor) (io.R
}
if resp.StatusCode > 299 {
resp.Body.Close()
if resp.StatusCode == http.StatusNotFound {
continue // try one of the other urls.
}
resp.Body.Close()
return nil, errors.Errorf("unexpected status code %v: %v", u, resp.Status)
}