-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Make 303 redirects do GET like Net Framework #49095
Conversation
…m to net Framework behaviour - issue 28998
Tagging subscribers to this area: @dotnet/ncl Issue DetailsMake PUT redirects do GET like Net Framework In Net Framework, PUT redirects do a GET. Fix #28998
|
I think we need to have consensus on what the right behavior here is in #28998 before we can consider taking this PR. I'll add my comments there shortly. |
You should add tests covering code changes @TimothyByrd. I agree with @geoffkizer that we should reach consensus on #28998 first. |
I did. They are in src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.AutoRedirect.cs |
yield return new object[] { statusCode, "PUT", statusCode == 303 ? "GET" : "PUT" }; | ||
yield return new object[] { statusCode, "DELETE", statusCode == 303 ? "GET" : "DELETE" }; | ||
yield return new object[] { statusCode, "PATCH", statusCode == 303 ? "GET" : "PATCH" }; | ||
yield return new object[] { statusCode, "OPTIONS", statusCode == 303 ? "GET" : "OPTIONS" }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The one thing I'd add here is a completely custom method, e.g. "MYCUSTOMMETHOD" or whatever, and validate it gets changed to GET on 303.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done - first i verified that an incorrect test of
yield return new object[] { statusCode, "MYCUSTOMMETHOD", "MYCUSTOMMETHOD" };
fails and then that the correct
yield return new object[] { statusCode, "MYCUSTOMMETHOD", statusCode == 303 ? "GET" : "MYCUSTOMMETHOD" };
passes
(I like breaking tests so I can tell I did something when I make them work)
Overall this looks good, just one comment to add an addition test case above. |
case HttpStatusCode.MultipleChoices: | ||
return requestMethod == HttpMethod.Post; | ||
case HttpStatusCode.SeeOther: | ||
return requestMethod != HttpMethod.Head; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more nit: I think this should return false when requestMethod == HttpMethod.Get.
It probably doesn't make much difference, but it seems better to treat this as not changing the method, as we do with GET in other cases like Moved. If nothing else, it will avoid an unnecessary and confusing trace call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay - done.
/azp run runtime-libraries-coreclr outerloop |
Azure Pipelines successfully started running 1 pipeline(s). |
CI failures look unrelated, will merge |
Thanks for your contribution, @TimothyByrd! |
* upstream/main: (83 commits) Fix a crash in llvm if the sreg of a setret is not set because the methods ends with a throw. (dotnet#49122) [macOS-arm64] Disable failing libraries tests (dotnet#49400) improve PriorityQueue documentation (dotnet#49392) [wasm] Fix debugger tests (dotnet#49206) [mono] Fix the emission of EnumEqualityComparer instances into the corlib AOT image. (dotnet#49402) jitutils M2M renaming reaction (dotnet#49430) WinHttpHandler: Read HTTP/2 trailing headers [RyuJIT] Make casthelpers cold for sealed classes (dotnet#49295) JIT: Non-void ThrowHelpers (dotnet#48589) Update package index for servicing (dotnet#49417) Remove unnecessary check on polymorphic serialization (dotnet#48464) Remove release build cron triggers from jitstress jobs (dotnet#49333) [main] Update dependencies from dotnet/arcade dotnet/llvm-project dotnet/runtime-assets (dotnet#49359) Implement AppleCryptoNative_X509GetRawData using SecCertificateCopyData [AndroidCrypto] Support a zero-length salt for HMACs. (dotnet#49384) Use managed implementation of pbkdf2 for Android's one-shot implementation. (dotnet#49314) Make 303 redirects do GET like Net Framework (dotnet#49095) Make sure event generation is incremental (dotnet#48903) Add amd and Surface arm64 perf runs (dotnet#49389) Enregister EH var that are single def (dotnet#47307) ...
Make 303 redirects do GET like Net Framework
In Net Framework, PUT redirects on a 303 do a GET.
Net 5.0 breaks compatibility with this.
See #28998
This commit causes redirects of a 303 to do a GET
for POST (existing behavior), PUT, DELETE, PATCH and OPTIONS
Fix #28998