diff --git a/registry/tokentransport.go b/registry/tokentransport.go index 4e858b04..f955d312 100644 --- a/registry/tokentransport.go +++ b/registry/tokentransport.go @@ -14,12 +14,21 @@ type TokenTransport struct { } func (t *TokenTransport) RoundTrip(req *http.Request) (*http.Response, error) { + + var err error + resp, err := t.Transport.RoundTrip(req) if err != nil { return resp, err } if authService := isTokenDemand(resp); authService != nil { - resp.Body.Close() + _ = resp.Body.Close() + if req.GetBody != nil { + req.Body, err = req.GetBody() + if err != nil { + return resp, err + } + } resp, err = t.authAndRetry(authService, req) } return resp, err