This adapts the existing HttpClientMiniStress tests to run with HTTP/2 as well as HTTP/1.1. Some caveats, though:
- All of these existing tests spin up a new server per request, so they're not stressing arguably the most important aspect of the client's HTTP/2 implementation, that of sharing the single connection across all requests. Our loopback server is not currently robust enough to handle concurrent requests; we should look at switching over to using Kestrel.
- The tests run really slowly, ~40x slower than for HTTP/1.1. However, the HTTP/1.1 tests are non-SSL, these are of course SSL, and it looks like that's actually the difference. In particular, something about how our test server gets its test certificate appears to be taking the vast majority of the time. (We should separately see if we could tweak that, not just for this purpose, but more so to help speed up the whole suite.)
Commit migrated from https://github.com/dotnet/corefx/commit/a7c893ab3d3e50b11c7fa2338882c8964e0a290d
* Factor out repo restore into seperate props/targets
* Use configuration system msbuild sdk
* Remove XUnit.Runtime.depproj
* Remove TargetGroup usages in test projects
* Fix ILLink configuration
The ILLink package contains netcoreapp2.0 assets which are compatible
with netstandard2.0. Removing the old TargetFramework to restore
successfully.
* Remove usages from TargetGroup in Directory.Build.props
* Remove dead net4* configurations
* Change tests.builds to tests.proj sdk proj
* Make externals dir proj an sdk project
* Consume Microsoft.DotNet.CoreFxTesting as an msbuild sdk
* Use runtimeconfig.template.json
* Remove SupplementalTestData
* Map shared framework version to product version
* Stop binplacing tests
* Move some tool depprojs to targets during restore
* Remove dead code
* Use PackageReference instead of RefFromRuntime in test
* Disable using an apphost
* Copy compression testdata manually cause unicode bug
* Remove target batching in optimizationData
* Reference packaging tools from CoreFx.Private.TestUtilities
Commit migrated from https://github.com/dotnet/corefx/commit/c4c1985531cc1f25c805bbc4801b85c98e0dfee0
* HPACK correctness tests/updates. Resolvesdotnet/corefx#31316.
Fixes:
- Fix check allowing out-of-bounds write in IntegerEncoder when an integer requires more than one byte and there is not enough buffer space.
- Encode Content-Type with a "Literal Header Without Indexing -- Indexed Name" rather than with a literal name.
Updates: (ported from ASP.NET HPACK code)
- Dynamic table size update must be the first instruction in the header block. Throw an exception when not the case.
- Throw an exception when we've reached the end of header data and we are still mid-parse.
New:
- Asserts, documentation, and tests for IntegerEncoder and IntegerDecoder.
- Tests to verify HttpClient is correctly encoding the different variants of headers.
- HPackDecoder tests (ported from ASP.NET)
* Address review feedback and fix CI.
* Address review feedback.
* Fix licensing to use ASP.NET's licensing. Add a TPN.
Commit migrated from https://github.com/dotnet/corefx/commit/ed526597f3f0d4653588ba0129fcaf18e2e5a4ef
* Change EstablishConnectionAndProcessOneRequestAsync test method to use WhenAllOrAnyFailed
CI is currently hanging when the client operation fails in a way that the server never hears about the request, and waits forever.
* Address PR feedback
Commit migrated from https://github.com/dotnet/corefx/commit/0b5479dde70fc565c5edefac4259578865496e84
The GoAwayFrame_AbortAllPendingStreams_StreamFailWithExpectedException test has been frequently hanging on some Linux distros. This adds some diagnostics to help track it down in CI: every minute, it'll dump out the fields of the async state machine, which if nothing else will let us see which await it's stuck on and what is the state of each of the tasks.
Commit migrated from https://github.com/dotnet/corefx/commit/410a162f68eb319e8066ac7bf2d7bcd6e2ce47d0
There are logic errors in ConnectHelper's catch blocks regarding cancellation. It's catching all exceptions and then trying to decide whether it should wrap the exception in an OperationCanceledException (based on whether cancellation was requested), but it's ignoring the possibility that the exception already is an OperationCanceledException.
Commit migrated from https://github.com/dotnet/corefx/commit/80252bbc5cf2f933aef1f30d6bec7deaa3064f54
* expect100
* updates
* remove dead code
* fix tests
* use configured value for allowExpect100ToContinue timer
* feedback from review
* dispose expect100Timer
* feedback from review
* feedback from review
* feedback from review
* small updates to sync up with master changes
* add concurent send/recive and more tests
* fix netfx
* feedback from review
* feedback from review
* feedback from review
* feedback from review
* feedback from review
* kick ci
Commit migrated from https://github.com/dotnet/corefx/commit/b4fa2006c2e9757e4446e3fdad413bdbf265eedc
CancellationToken.Register captures the current ExecutionContext and uses it to invoke the callback if/when it's invoked. That's generally desirable and is the right default, but in cases where we know for certain the callback doesn't care about EC (e.g. we're not invoking any 3rd-party code), we can use UnsafeRegister instead (newly added in 3.0), which skips capturing the ExecutionContext, as if Capture returned null. This helps few a couple of small costs:
- Avoids thread local lookups to capture the current EC.
- Avoids additional delegate invocations and thread local gets/sets to invoke the callback with the captured EC.
- Avoids holding on to the EC in case it's needed, which can potentially keep alive an unbounded amount of state due to AsyncLocals.
Commit migrated from https://github.com/dotnet/corefx/commit/b1a1bfa0997ce35e8540fbbe74276858e315807e
- string.IndexOf(string) and string.IndexOf(string, int) are culture-aware. For most situations in System.Net, that's undesirable and Ordinal is both more correct and faster.
- string.IndexOf("c", StringComparison.Ordinal) is better off as string.IndexOf('c') for perf and simplicity.
- string.IndexOf('c') >= 0 is better off as string.Contains('c') for perf and simplicity.
Commit migrated from https://github.com/dotnet/corefx/commit/6acc044c36df2138d86620e2c27d3234c4fa0d3d
* Log exceptions from asynchronously failing Expect: 100-continue sends
When Expect: 100-continue is used, the sending of the request body content is allowed to run concurrently with the receipt of the response headers. If the processing of the response headers encounters an exception, we currently fail to ever join with that send task, which results in a TaskScheduler.UnobservedTaskException event. This PR changes to observe the exception in such cases and log it.
(In doing so, I also came across an async void method, and changed all of the remaining ones in the assembly to be async Task instead. The current implementation of async void isn't any cheaper than async Task, and is actually more expensive in certain ways, plus it unnecessarily interacts with any SynchronizationContext that may exist.)
* Address PR feedback
Commit migrated from https://github.com/dotnet/corefx/commit/0bc3ee4a4f1debaa0dd3c957d5201ae2a47757a1
* improve error handling on failed Http/2 handshake
* remove extra space
* add test for HTTP2 client talking to HTTP1 server.
* fix broken tests
* improve exception handling
* update exception handling
* ws update
* fix bad merge
* update test and changes from dotnet/corefx#37223
* use _abortException only if the stream is not aborted already
* fix IsAborted check
* updates to syncup with recent changes
Commit migrated from https://github.com/dotnet/corefx/commit/c412fa7dc60559dc38050c63b2e34b5156a2499e
The server in the test was sending down the entire response and then trying to read the data from the client. If the client sent its whole payload and read the response before the server go around to doing the read, the client might close the connection, in which case the read might fail. The fix just changes the server code to only send down the headers, then read the data from the client, and only then finish the response, at which point it's fine if the client closes the connection.
Commit migrated from https://github.com/dotnet/corefx/commit/772aa2d1029caa8be3b360168b63dadd42ae788b
We now respect the version: if it's 1.1, we use 1.1, and if it's 2.0, we try to use HTTP/2. At the same time, the default for HttpRequestMessage.Version goes back to 1.1, so to use HTTP/2, you opt-in by setting the version explicitly to 2.0.
Commit migrated from https://github.com/dotnet/corefx/commit/d69d441dfb0710c2a34155c7c4745db357b14c96
This PR implements the new static HttpClient.DefaultProxy property which was approved
during API review.
Modify the SystemProxyInfo.ConstructSystemProxy method to a Singleton.
Modify SocketsHttpHandler to use the HttpClient.DefaultProxy property.
Rename the HttpSystemProxy class to HttpWindowsProxy.
Add some HttpClient tests for the new property.
Closesdotnet/corefx#36553
Commit migrated from https://github.com/dotnet/corefx/commit/c661db6ce2da91033671c0000afc185de1ad3fe9
In order to provide a consistent experience with the HttpClient IWebProxy objects,
the returned internal proxy object which represent the system/platform proxy settings
should never be null. If the platform's settings indicate that no proxy is being used,
then return an instance of the internal HttpNoProxy object.
Note that even if the platform settings indicate that a proxy could be used, any
particular Http request might still not go thru a proxy. The final determination of
what proxy is being used for a request is still governed by the return of the
IWebProxy.IsBypassed and IWebProxy.GetProxy methods.
Contributes to dotnet/corefx#36553
Commit migrated from https://github.com/dotnet/corefx/commit/830bf7fc0346d9453d85ad4ec726c92ac3e72998
A few tweaks:
- We hand out the ChunkedEncodingWriteStream and ContentLengthWriteStream to an HttpContent.SerializeToStreamAsync. If that user code disposes of the Stream, then we end up null ref'ing when we try to finish the processing. We should instead throw a more descriptive error about the misuse.
- Make the non-pooled response streams slightly more robust against concurrent disposal (which is not a supported use, but it happens).
Commit migrated from https://github.com/dotnet/corefx/commit/422565673deb849b42f656f4a68bec791ee4bed9
* Clean up HTTP/2 protocol exception handling
- Propagate the GOAWAY and RST_STREAM error codes to the calling code via an exception.
- Propagate to the Http2Stream exceptions incurred in the Http2Connection and that result in an Abort.
- Don't Dispose of the Http2Stream before we try to Cancel it.
- Make Http2ProtocolException serializable, as we generally do that for all of our exception types.
- Add tests that verify sufficient HTTP/2 protocol details are in the exception messages.
- Clean up the error message for the exception.
- Separate the error code and exception into their own files.
- Leave Http2ProtocolException internal for now; we can expose it publicly when we design the all-up public error model for HttpClient.
* Address PR feedback
Commit migrated from https://github.com/dotnet/corefx/commit/7237da089c09531c36a2110a3bdd9ccaf7c05d77
Changed the Windows version of SocketsHttpHandler so that it will honor the same environment
variables similar to the Linux and OSX versions. If the environment variables are not set
then it reverts back to the Windows WinInet/IE settings behavior.
I added several kinds of unit and end-to-end tests to verify the SystemProxyInfo class is
making the correct choice for all the different platforms regarding whether the
HttpEnvironmentProxy or platform proxy (HttpSystemProxy for Windows and MacProxy for OSX)
is used.
Fixesdotnet/corefx#37187
Commit migrated from https://github.com/dotnet/corefx/commit/4f27d0f84c17850ef02ea7b330908fddcdf73c86