Webcmdlets add 308 to redirect codes and small cleanup#18536
Webcmdlets add 308 to redirect codes and small cleanup#18536iSazonov merged 8 commits intoPowerShell:masterfrom
Conversation
|
@CarloToso This change can be very sensitive. We need detailed description of the scenario(s) you are trying to fix. |
|
The status codes 300,301,302,303,307,308 are redirect codes, and should have similar behaviour. |
|
Another option could be completely removing this non terminating error. So we have the same behaviour for -MaximumRedirection >= 0 |
|
@CarloToso While I agree that 308 is redirect code and should be handled in some way I have a concern that the PR changes not one scenario but same ones. Supporting the HTTP client is a difficult task. We usually compare the behavior with wget. If you can create tests that work the same way for both clients, that would be convincing for reviewers. |
|
@iSazonov I wrote this small test to compare curl, wget and invoke-webrequest for ($maxredirs = 0; $maxredirs -le 2; $maxredirs++)
{
Write-Host "MaximumRedirection == $maxredirs" -BackgroundColor Red
Write-Host "-------------------Invoke-WebRequest-------------------"
300,301,302,303,307,308 | ForEach-Object {Invoke-WebRequest "http://mockbin.org/redirect/$($_)?to=https://mockbin.org/redirect/302?to=https://mockbin.org/status/200" -Method HEAD -MaximumRedirection $maxredirs -SkipHttpErrorCheck}
Write-Host "-------------------curl-------------------"
300,301,302,303,307,308 | ForEach-Object {$x = curl.exe -LI --no-progress-meter "http://mockbin.org/redirect/$($_)?to=https://mockbin.org/redirect/302?to=https://mockbin.org/status/200" --max-redirs $maxredirs; ($x -join"`n").split("`n`n")[-1]}
Write-Host "-------------------wget-------------------"
300,301,302,303,307,308 | ForEach-Object {$x = .\wget.exe http://mockbin.org/redirect/$($_)?to=https://mockbin.org/redirect/302?to=https://mockbin.org/status/200 --max-redirect $maxredirs --spider --server-response 2>&1; ($x[0..($x.length-2)] -join"`n").split("Spider mode enabled. Check if remote file exists.")[-1]}
}flags explained It looks like they have similar behaviours:
I wasn't able to parse the maximum redirections exceded error correctly in wget, to visualize it use:
Maybe it might be useful in some edge cases, if that is the case adding the other redirect codes would be the right thing to do |
Thanks for your investigations! Can you share outputs (or screenshots)? For 308 particularly. |
|
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
|
This PR has Quantification details
Why proper sizing of changes matters
Optimal pull request sizes drive a better predictable PR flow as they strike a
What can I do to optimize my changes
How to interpret the change counts in git diff output
Was this comment helpful? 👍 :ok_hand: :thumbsdown: (Email) |
|
Is something blocking this PR? |
Waiting review from @PaulHigin. |









PR Summary
Add 308 to possible redirect codes
Small cleanup of a nested if
PR Context
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.(which runs in a different PS Host).