Add support and tests for HTTP 308 Permanent Redirect#30398
Add support and tests for HTTP 308 Permanent Redirect#30398rmkerr merged 5 commits intodotnet:masterfrom
Conversation
|
@dotnet-bot test Outerloop Windows x64 Debug Build |
|
|
||
| new object[] { 308, "GET", "GET" }, | ||
| new object[] { 308, "POST", "POST" }, | ||
| new object[] { 308, "HEAD", "HEAD" }, |
There was a problem hiding this comment.
I'll be interested to see if this passes on NetfxHandler and CurlHandler.
There was a problem hiding this comment.
And UapHandler, since:
corefx/src/System.Net.Http/src/uap/System/Net/HttpHandlerToFilter.cs
Lines 115 to 122 in 015ee21
There was a problem hiding this comment.
Agreed. I think it's possible that it will also fail in WinHttpHandler on win7. If so though I think we should keep the change and disable the test on those platforms. I'll extend the fix to UAP though, since we can control the behavior there.
| case HttpStatusCode.SeeOther: | ||
| case HttpStatusCode.TemporaryRedirect: | ||
| case HttpStatusCode.MultipleChoices: | ||
| case HttpStatusCode.PermanentRedirect: |
There was a problem hiding this comment.
This will probably need to be updated too. It looks like the test for MaxAutomaticRedirections only uses 302, so I'll add an additional test for that case.
corefx/src/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.cs
Lines 1083 to 1132 in 909dc9e
There was a problem hiding this comment.
@stephentoub I added the new redirect code here, but it is causing build failures on netfx. I can use the integer 308 instead, or do you think I should take a different approach?
There was a problem hiding this comment.
Using "308" might still fail on NETFX since it might not be supported. You can try though using the integer. But if the test fails, then you'll need to skip that test case on NETFX.
There was a problem hiding this comment.
NETFX does NOT support 308 redirect code:
|
@dotnet-bot Test Outerloop OSX x64 Debug Build |
|
It looks like the redirect tests that are using the remote echo server are failing with a 500 error: I'm going to take a look at the remote echo server code to see if it is causing these failures. |
| } | ||
|
|
||
| [SkipOnTargetFramework(TargetFrameworkMonikers.Uap, "Not currently supported on UAP")] | ||
| [OuterLoop] // TODO: Issue #11345 |
There was a problem hiding this comment.
We're trying to remove the obsoleted TODO 11345.
Instead this should be "[Outerloop("Use external server")]"
|
The remote echo server will need to updated: if (statusCode < 300 || statusCode > 307)
{
context.Response.StatusCode = 500;
context.Response.StatusDescription = "Invalid redirect statuscode: " + statusCodeString;
return;
}I will handle that. And the source code for it in CoreFx is not actually up to date with the real deployed code. That is done from a different repo. |
|
@davidsh Thanks for taking care of it. For future reference, where is that repo? |
Let's discuss offline in team meeting. To update the service, it's more complex than just knowing where the repo is. |
|
Thanks! I'll rerun the tests. @dotnet-bot test Outerloop Windows x64 Debug Build |
|
I think the test failures here are a combination of three issues:
|
Having multiple hops was only about testing the "limits" we set for MaxAutomaticRedirection in the handlers. It wasn't about whether it was "realistic" behavior of clients, i.e. browsers. I would rather we don't touch the current behavior of the redirect.ashx endpoint for this. And we should fix/remove the tests as needed. I don't think it is necessary to have multi-hop tests for all redirect status codes. |
|
@davidsh Okay, in that case I'll just remove that test. We have a multi-hop test for 302 and single hop tests for all other status codes, so that should cover it. |
davidsh
left a comment
There was a problem hiding this comment.
LGTM. You'll also want to re-run all Outerloop tests again since you've revised the PR.
|
@dotnet-bot test Outerloop Windows x64 Debug Build |
|
Rerunning the tests since this has been inactive for almost a month. If the tests look good I'll go ahead and merge this. @dotnet-bot test Outerloop Windows x64 Debug Build |
|
I'm going to go ahead and merge this change. The Linux Outerloop failure was in System.Drawing, and is unrelated. The OSX failure is a known flaky HTTP test that does not use redirection. |
This change adds support for 308 redirects to SocketsHttpHandler, and enables 308 redirects in our tests. Fixes: #30389
…30398) This change adds support for 308 redirects to SocketsHttpHandler, and enables 308 redirects in our tests. Fixes: dotnet/corefx#30389 Commit migrated from dotnet/corefx@12e41ed
…30398) This change adds support for 308 redirects to SocketsHttpHandler, and enables 308 redirects in our tests. Fixes: dotnet/corefx#30389 Commit migrated from dotnet/corefx@12e41ed

The HttpStatusCode enum was only recently updated to include HTTP status code 308, via PR #26727. With the platform handlers we support whatever cURL and WinHttp support, so 308 works even though the status code did not exist in the enum until recently. However in SocketsHttpHandler we only support the redirects that were in the enum when that code was written, which at the time did not include 308.
This PR adds support for 308 redirects to SocketsHttpHandler, and enables 308 redirects in our tests. It is not well documented when WinHttp and cURL added support for HTTP 308, so it is possible these tests will fail on older operating systems. If so I believe we should still take the change, but should add documentation on our support on older systems.
Fixes: #30389