Allow HEAD to redirect, but default to it not #160
Closed
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.
Right now, if you are doing a
HEAD
request redirects are never followed.but they are for
GET
and all other methods.My reading of the spec
is that HEAD and GET are both allowed to follow redirects.
though I understand why maybe one would not want to with HEAD since you could be looking to check if there was a redirect going on or some other header information at that point.
So the way I made it possible to have it both ways (and not change behaviour (much))
is to make using the HEAD method set the default value of maxredirects to 0,
rather than blocking redirects directly.
I thinking any user setting
maxredirects
to any value (other than 0 themselves) when using HEAD, clearly does want redirects to happen.This needs tests and docs, but I wanted to put it forward for discussion before I took it any further