Merge pull request #5712 from coryb/docker-push-close-body

Fix missing Body.Close() calls on push to docker remote
This commit is contained in:
Phil Estes 2021-07-12 14:23:14 -04:00 committed by GitHub
commit b6aa5a48bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -190,6 +190,7 @@ func (p dockerPusher) push(ctx context.Context, desc ocispec.Descriptor, ref str
return nil, err
}
}
defer resp.Body.Close()
switch resp.StatusCode {
case http.StatusOK, http.StatusAccepted, http.StatusNoContent:
@ -382,6 +383,7 @@ func (pw *pushWriter) Commit(ctx context.Context, size int64, expected digest.Di
if resp.err != nil {
return resp.err
}
defer resp.Response.Body.Close()
// 201 is specified return status, some registries return
// 200, 202 or 204.