Skip to content
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

Fixed Custom Redirect being used regardless if followRedirect is false #69

Merged
merged 1 commit into from Aug 6, 2023
Merged

Conversation

ghost
Copy link

@ghost ghost commented Aug 5, 2023

In net/http, when defining a redirect function whether to follow or disable redirects, you must always define a custom function in the transport. Using the custom redirect func in the clientConfig, it causes the .SetFollowRedirect() function to never work if provided with "false". By adding a check to ensure that follow redirects is enabled when updating the underlying client's transport, it allows you to enable and disable redirects per request, while also maintaining the custom redirect function when re-enabling follow redirects.

In net/http, when defining a redirect function whether to follow or disable  redirects, you must always define a custom function in the transport. Using the custom redirect func in the clientConfig, it causes the .SetFollowRedirect() function to never work if provided with "false". By adding a check to ensure that follow redirects is enabled when updating the underlying client's transport, it allows you to enable and disable redirects per request, while also maintaining the custom redirect function when re-enabling follow redirects.
@bogdanfinn
Copy link
Owner

@sm0ke88 thank you for your contribution!

@bogdanfinn bogdanfinn merged commit a5ea8cb into bogdanfinn:master Aug 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant