diff --git a/registry/registry.go b/registry/registry.go index 5c118efc..c63321d9 100644 --- a/registry/registry.go +++ b/registry/registry.go @@ -71,14 +71,14 @@ func WrapTransport(transport http.RoundTripper, url, username, password string) Username: username, Password: password, } - //basicAuthTransport := &BasicTransport{ - // Transport: tokenTransport, - // URL: url, - // Username: username, - // Password: password, - //} - errorTransport := &ErrorTransport{ + basicAuthTransport := &BasicTransport{ Transport: tokenTransport, + URL: url, + Username: username, + Password: password, + } + errorTransport := &ErrorTransport{ + Transport: basicAuthTransport, } return errorTransport } diff --git a/registry/tokentransport.go b/registry/tokentransport.go index 4e858b04..05760951 100644 --- a/registry/tokentransport.go +++ b/registry/tokentransport.go @@ -3,6 +3,7 @@ package registry import ( "encoding/json" "fmt" + "io/ioutil" "net/http" "net/url" ) @@ -20,6 +21,9 @@ func (t *TokenTransport) RoundTrip(req *http.Request) (*http.Response, error) { } if authService := isTokenDemand(resp); authService != nil { resp.Body.Close() + if req.Body != nil { + ioutil.ReadAll(req.Body) + } resp, err = t.authAndRetry(authService, req) } return resp, err