-
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
Remove Uri scheme validation from HttpRequestMessage #55035
Conversation
Tagging subscribers to this area: @dotnet/ncl Issue DetailsFixes #52836 Removed the Uri scheme check from Any scheme will be passed to handlers. No merge: Should other handlers have filters for specific schemes?
|
src/libraries/System.Net.Http/src/System/Net/Http/HttpRequestMessage.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/SocketsHttpHandler.cs
Show resolved
Hide resolved
src/libraries/System.Net.Http/tests/UnitTests/System.Net.Http.Unit.Tests.csproj
Show resolved
Hide resolved
Yeah, we should add the same logic to WinHttpHandler. |
src/libraries/System.Net.Http/src/System/Net/Http/HttpClient.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Http/tests/FunctionalTests/SocketsHttpHandlerTest.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Http/tests/FunctionalTests/SocketsHttpHandlerTest.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Http/tests/FunctionalTests/SocketsHttpHandlerTest.cs
Show resolved
Hide resolved
With this PR:
@lewing is this the desired behavior for Browser, or should we be filtering out relative Uris? |
/azp run runtime-libraries-coreclr outerloop |
Azure Pipelines successfully started running 1 pipeline(s). |
src/libraries/System.Net.Http.WinHttpHandler/src/Resources/Strings.resx
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Http.WinHttpHandler/tests/FunctionalTests/WinHttpHandlerTest.cs
Outdated
Show resolved
Hide resolved
HttpTelemetry.Log.IsEnabled() && | ||
!request.WasSentByHttpClient() && | ||
request.RequestUri is Uri requestUri && | ||
requestUri.IsAbsoluteUri; |
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.
Why do we disable telemetry if the Uri isn't absolute?
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 call to RequestStart
that follows this check will access Uri fields that would throw for relative Uris.
Adding this check here so that you get the meaningful exception message from SocketsHttpHandler
instead.
src/libraries/System.Net.Http/src/System/Net/Http/MessageProcessingHandler.cs
Outdated
Show resolved
Hide resolved
{ | ||
return task.ContinueWith(continuation, state, CancellationToken.None, | ||
TaskContinuationOptions.ExecuteSynchronously, TaskScheduler.Default); | ||
} |
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.
Good riddance. Thanks!
Move HttpUtilities to SocketsHttpHandler
9eb1416
to
da8844d
Compare
Fixes #52836
Removed the Uri scheme check from
HttpRequestMessage
/HttpClient.BaseAddress
and moved it inSocketsHttpHandler.ValidateAndNormalizeRequest
.Any scheme will be passed to handlers.
No merge: Should other handlers have filters for specific schemes?
WinHttpHandler
takes 85 seconds to figure out it can't processfoo://httpbin.org
without a fail-fast like this for example.Added
http
/https
checks toWinHttpHandler
.