-
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
Sync HttpClient Send #34948
Sync HttpClient Send #34948
Conversation
…socketshttphandlersync stephentoub/corefx@0e4d640 Little compilation fix. Compilaris Test compilaris Fixed buffer sending not passing offset and count.
Conflicts: src/libraries/Common/tests/System/Net/Http/LoopbackServer.cs src/libraries/System.Net.Http/src/System.Net.Http.csproj src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs
# Conflicts: # src/libraries/System.Net.Http/ref/System.Net.Http.cs # src/libraries/System.Net.Http/src/System.Net.Http.csproj # src/libraries/System.Net.Http/src/System/Net/Http/DiagnosticsHandler.cs # src/libraries/System.Net.Http/src/System/Net/Http/HttpClient.cs # src/libraries/System.Net.Http/src/System/Net/Http/HttpContent.cs # src/libraries/System.Net.Http/src/System/Net/Http/MultipartContent.cs # src/libraries/System.Net.Http/src/System/Net/Http/ReadOnlyMemoryContent.cs # src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/AuthenticationHelper.NtAuth.cs # src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/AuthenticationHelper.cs # src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http3Connection.cs # src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnection.cs # src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionBase.cs # src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs # src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPoolManager.cs # src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpContentWriteStream.cs # src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/SocketsHttpHandler.cs # src/libraries/System.Net.Http/src/System/Net/Http/StreamContent.cs
# Conflicts: # src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionBase.cs # src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs
Note regarding the This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change. |
Tagging subscribers to this area: @dotnet/ncl |
/azp list |
/azp run runtime-libraries outerloop |
Azure Pipelines successfully started running 1 pipeline(s). |
a25bcf2
to
007cfbe
Compare
a3ebd67
to
3593372
Compare
a53c23c
to
96eccce
Compare
/azp run runtime-libraries outerloop |
Azure Pipelines successfully started running 1 pipeline(s). |
This PR has failures in DiagnosticHandler. I think this is caused by known issue #38205 |
Results from our micro benchamarks, pr vs master: BenchmarkDotNet=v0.12.1, OS=manjaro
Intel Core i7-4771 CPU 3.50GHz (Haswell), 1 CPU, 8 logical and 4 physical cores
.NET Core SDK=5.0.100-preview.6.20310.4
[Host] : .NET Core 5.0.0 (CoreCLR 5.0.20.30506, CoreFX 5.0.20.30506), X64 RyuJIT
Job-DJGXQP : .NET Core 5.0 (CoreCLR 42.42.42.42424, CoreFX 42.42.42.42424), X64 RyuJIT
Job-LKRKYA : .NET Core 5.0 (CoreCLR 42.42.42.42424, CoreFX 42.42.42.42424), X64 RyuJIT
PowerPlanMode=00000000-0000-0000-0000-000000000000 Arguments=/p:DebugType=portable IterationTime=250.0000 ms
MaxIterationCount=20 MinIterationCount=15 WarmupCount=1
I ran it several times. Sometimes it would show a regression in one test, other times in another. When I isolated them, I got somewhat unstable results (sometimes was my PR faster, sometimes master). Due to this, I don't think there's a perf regression per se. |
Ok, thanks for checking. Any differences appear to be within noise. |
All outerloop errors are unrelated (#38205). |
Introduces sync version of HttpClient.Send and all necessary changes to make it work synchronously (e.g.: HttpContent, HttpMessageHandler and their child classes). The change works properly only for HTTP1.1, for unsupported scenarios like HTTP2 throws. Testing the change uses existing tests calling HttpClient.SendAsync and introduces test argument calling the same test twice, once with HttpClient.SendAsync and then with HttpClient.Send. Resolves dotnet#32125
@@ -537,9 +551,17 @@ public Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, HttpCompl | |||
} | |||
|
|||
// Buffer the response content if we've been asked to and we have a Content to buffer. | |||
if (response.Content != null) | |||
if (buffered && response.Content != null) |
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.
Should it also check: response.Content is not EmptyContent
?
After updating an app from .NET Core 3.1 to .NET 5.0, I am hitting ObjectDisposedException:
---- System.ObjectDisposedException : Cannot access a disposed object.
Object name: 'System.Net.Http.EmptyContent'.
Stack Trace:
at System.Net.Http.HttpContent.CheckDisposed()
at System.Net.Http.HttpContent.LoadIntoBufferAsync(Int64 maxBufferSize, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.SendAsyncCore(HttpRequestMessage request, HttpCompletionOption completionOption, Boolean async, Boolean emitTelemetryStartStop, CancellationToken cancellationToken)
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.
Nvm, it was a bug in test, which 3.1 was tolerating and 5.0 makes sure the objects are disposed properly: https://github.com/actions/runner/pull/799/files#diff-f7999ffa872c1d85e7368f4c351978e3d2a4ad3e3b9a27547234ede8e26bdaf5.
Introduces sync version of
HttpClient.Send
and all necessary changes to make it work synchronously (e.g.:HttpContent
,HttpMessageHandler
and their child classes).The change works properly only for HTTP1.1, for HTTP2 does sync-over-async.
Also for client authentication uses sync-over-async, this is an ongoing issue being separately handled in #34638.
Testing the change uses existing tests calling
HttpClient.SendAsync
and introduces test argument calling the same test twice, once withHttpClient.SendAsync
and then withHttpClient.Send
.Resolves #32125