Skip to content

Commit

Permalink
恢复http base auth. 并在请求认证失败后,定位读取指针至末端。
Browse files Browse the repository at this point in the history
  • Loading branch information
kychen committed May 25, 2020
1 parent 4653320 commit cbd7e19
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
14 changes: 7 additions & 7 deletions registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 4 additions & 0 deletions registry/tokentransport.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package registry
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"net/url"
)
Expand All @@ -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
Expand Down

0 comments on commit cbd7e19

Please sign in to comment.