File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -539,7 +539,21 @@ func (r *request) do(ctx context.Context) (*http.Response, error) {
539539 if err := r .authorize (ctx , req ); err != nil {
540540 return nil , errors .Wrap (err , "failed to authorize" )
541541 }
542- resp , err := ctxhttp .Do (ctx , r .host .Client , req )
542+
543+ var client = & http.Client {}
544+ if r .host .Client != nil {
545+ * client = * r .host .Client
546+ }
547+ if client .CheckRedirect == nil {
548+ client .CheckRedirect = func (req * http.Request , via []* http.Request ) error {
549+ if len (via ) >= 10 {
550+ return errors .New ("stopped after 10 redirects" )
551+ }
552+ return errors .Wrap (r .authorize (ctx , req ), "failed to authorize redirect" )
553+ }
554+ }
555+
556+ resp , err := ctxhttp .Do (ctx , client , req )
543557 if err != nil {
544558 return nil , errors .Wrap (err , "failed to do request" )
545559 }
You can’t perform that action at this time.
0 commit comments