Merge pull request #5504 from dmcgowan/fix-authorization-on-redirect
Update docker resolver to authorize redirects
This commit is contained in:
commit
bf1a6678b9
@ -539,7 +539,21 @@ func (r *request) do(ctx context.Context) (*http.Response, error) {
|
|||||||
if err := r.authorize(ctx, req); err != nil {
|
if err := r.authorize(ctx, req); err != nil {
|
||||||
return nil, errors.Wrap(err, "failed to authorize")
|
return nil, errors.Wrap(err, "failed to authorize")
|
||||||
}
|
}
|
||||||
resp, err := ctxhttp.Do(ctx, r.host.Client, req)
|
|
||||||
|
var client = &http.Client{}
|
||||||
|
if r.host.Client != nil {
|
||||||
|
*client = *r.host.Client
|
||||||
|
}
|
||||||
|
if client.CheckRedirect == nil {
|
||||||
|
client.CheckRedirect = func(req *http.Request, via []*http.Request) error {
|
||||||
|
if len(via) >= 10 {
|
||||||
|
return errors.New("stopped after 10 redirects")
|
||||||
|
}
|
||||||
|
return errors.Wrap(r.authorize(ctx, req), "failed to authorize redirect")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := ctxhttp.Do(ctx, client, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "failed to do request")
|
return nil, errors.Wrap(err, "failed to do request")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user