-
Notifications
You must be signed in to change notification settings - Fork 251
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
Add support for CheckRedirect in Client.StandardClient() #128
base: main
Are you sure you want to change the base?
Conversation
To clarify the check in Do could possibly be removed by using a setter function instead of exported variable. So that's why the check is there so you could create the client, do a request, change the CheckRedirect variable and the next request would work. Cheers! |
Hey @nuttmeister ! Thanks for opening this.
Could you clarify why you are unable to set the c := retryablehttp.NewClient()
c.HTTPClient.CheckRedirect = ... I could be missing something, let me know! |
@ryanuber hey! I tried setting it on both So totally possible some of this PR is not really necessary. Didn't think that one through 100%. |
@ryanuber I have narrowed it down basically (I think). Using just the regular none standard But if you use the standard However, what DOES does work that I just found out is actually doing this: client := NewClient()
client.HTTPClient.CheckRedirect = func(req *http.Request, via []*http.Request) error {
return http.ErrUseLastResponse
}
stdClient := client.StandardClient()
stdClient.CheckRedirect = func(req *http.Request, via []*http.Request) error {
return http.ErrUseLastResponse
} Which is not really straight forward perhaps to get it working when using the standard client. But yeah, I will refactor the PR to copy these settings from what has been set in the |
Updated to just copy the the |
Long time with not activity. Is this something we want or should I close it? |
The CLA isn't signed yet so we cannot do anything with this PR at the moment, apologies. |
Hello. It was signed before. However I have changed companies twice and this email. The question is if it's wanted or not. If so I can try and sort it out. |
Yes, I think it's a good idea. |
@nuttmeister Wondering if you're able to get this ready to merge? Thanks! |
@manicminer sure, I just totally forgot about this. I will have a look at it today. |
6f4aee8
to
2677101
Compare
@manicminer there, force pushed with the now correct email that has signed the agreement. |
@nuttmeister Thanks, appreciate you picking up this old PR, I'm glad I can preserve your commit 🙂 |
Hello everyone!
This PR adds support for custom redirect behavior like the standard http.Client supports with the
CheckRedirect
function.Before this behavior couldn't be changed, not even on the default client returned by
StandardClient()
.It works using both
*Client
and*http.Client
fromStandardClient()
.For example, disabling follow redirect all together as follows.