Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There's currently no easy and intuitive way to change a client's redirect policy back to the default redirect policy.
For example: Let's say someone wants to send a
GET
request to a given URL, but is only interested in theLocation
header and the cookies of the response. They can usec.SetRedirectPolicy(req.NoRedirectPolicy())
to disable redirects and manually grab theLocation
header, but there's no simple way to "reset" the redirect policy back to the default one.They could go through req's source code until they find the following function, only to realize that they can achieve the same thing by setting the redirect policy to
req.MaxRedirectPolicy(10)
:req/client.go
Lines 324 to 332 in 24b0c84
This PR introduces
req.DefaultRedirectPolicy()
, which is essentially just an alias forreq.MaxRedirectPolicy(10)
, but greatly improves the developer experience in scenarios where someone wants to set a specific redirect policy, send out a couple of requests and then revert back to the default one.For relevant documentation changes, see imroc/req-website#239 (comment)