-
Notifications
You must be signed in to change notification settings - Fork 138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
grequests how to disable Redirect #72
Comments
maybe have some simple code to disable redirect? |
utils.go func addRedirectFunctionality(client *http.Client, ro *RequestOptions) {
if client.CheckRedirect != nil {
return
}
client.CheckRedirect = func(req *http.Request, via []*http.Request) error {
// here is new code
if ro.RedirectLimit == -1{
return http.ErrUseLastResponse
}
//over
if ro.RedirectLimit == 0 {
ro.RedirectLimit = RedirectLimit
}
if len(via) >= ro.RedirectLimit {
return ErrRedirectLimitExceeded
}
if ro.SensitiveHTTPHeaders == nil {
ro.SensitiveHTTPHeaders = SensitiveHTTPHeaders
}
for k, vv := range via[0].Header {
// Is this a sensitive header?
if _, found := ro.SensitiveHTTPHeaders[k]; found {
continue
}
for _, v := range vv {
req.Header.Add(k, v)
}
}
return nil
}
} |
I actually just found out that you posted this issue. I created a pull request #75 that fixes this. Hopefully @levigross will see it the same way. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I thought it would be like this.
But this code does not disable redirect,please tell me how to disable redirect, thanks~~~
The text was updated successfully, but these errors were encountered: