When using a timeout and/or a cancellation token with a buffered HttpClient operation, the cancellation/timeout doesn't flow through to the actual read/write operations on the underlying streams. This means that on Windows, doing a basic operation like GetStringAsync with a server that pauses for arbitrarily long periods of time while sending the response body won't cancel or timeout until it sends more data. (We don't need to do this on Unix, as on Unix we already handle this case differently, with a single registration for the duration of the SendAsync operation.)
Commit migrated from https://github.com/dotnet/corefx/commit/cc8b48c8ea41b9cee888055483d16072f3f3a1c5
Requires https://github.com/dotnet/buildtools/pull/751
This makes all the tests resolve using NETCoreApp1.0 instead of
DNXCore50. I've removed the netstandard1.6 import since that is no
longer needed. I've also removed the workarounds from tests that were
targeting netcoreapp1.0 on their own. For restore compat I've added an
DNXCore50 import to every test project. These can be removed once
test-runtime packages are updated to target NETCoreApp1.0.
I've updated all the test scripts which were assuming DNXCore50 as well
as docs which referred to this path.
Commit migrated from https://github.com/dotnet/corefx/commit/7ba4d296e3e0a2445ffa708c1e918d90d2bac69c
Reading from the response stream using ReadAsync() was ignoring the cancellation token passed in. To fix this, registered a delegate that will be called to dispose the WinHTTP request handle during pending I/O. This will cause the WinHTTP operation to cancel.
Added tests. For now, left them disabled to be resolved in issue dotnet/corefx#8692 next week. But wanted to get this fix in asap since it blocks partners for RTM.
Fixesdotnet/corefx#8662.
Commit migrated from https://github.com/dotnet/corefx/commit/a6e019d8e1910b9fed3c1077be23bfd9023d2837
When a server offers multiple auth schemes, WinHttpHandler is supposed
to select the more secure scheme regardless of the order of the
authentication headers. So, despite a server offering Basic and
Negotitate (in that order), Negotiate would be selected.
When using default credentials, however, it was not calling
WinHttpSetCredentials(null, null). This resulted in the first scheme
offered by the server (Basic) to be attempted. But there were no
credentials set and so a 401 resulted.
Fix WinHttpHandler so that it will always call WinHttpSetCredentials
even with default credentials. This ensures that the selected auth
scheme (in this case Negotiate) is used correctly.
Revised test configuration instructions. An IHttpModule is used for the
test server endpoint to ensure that IIS will put 'Basic' first in the
response headers.
Commit migrated from https://github.com/dotnet/corefx/commit/9c6821d9d39ebe67b03f6e491489ffbb44844612
- Add "debian.8-x64". This is the correct rid for Debian, after this
lands, I will need to update CI before we can remove "debian.8.2-x64"
- Add a generic "linux-x64" rid which we can use in cases where we want
to build for a distro where we don't yet have a set of runtime
packages. This will let us restore the managed assets (since they are
specific to "unix" or "linux" and then folks can do a native build to
get the shims and runtime and copy them over (this is a more
reasonable approach than our current strategy of just using
ubuntu.14.04-x64)
- Sort runtime sections
Commit migrated from https://github.com/dotnet/corefx/commit/6fa4bc1d215d17ff484aa3f541c5e3181f6918de
To support future security improvements, the default value for WinHttpHandler.SslProtocols will use the enum value of .None. This means that no preferred list of protocols is being expressed. And that means to use the best OS defaults. Currently this translates into using "Tls10 | Tls11 | Tls12".
This list will change over time as platforms adopt newer Tls versions and phase out older versions.
Commit migrated from https://github.com/dotnet/corefx/commit/9530ca89d99e2778d7882847230c462798e59544
It turns out that setting the WinHTTP 'Connect' timeout does nothing. We discovered this because we still got ERROR_WINHTTP_TIMEOUT errors after about 20 seconds even after setting the 'Connect' timeout to INFINITE. We discussed this with the WinHTTP team and they told us that this timeout is essentially deprecated due to performance enhancements in the TCP stack.
For the technically curious, here is the explanation. Underneath the 'Connect' timeout is really a set of TCP timeouts related to setting up the socket via the 3-leg SYN/ACK exchange. The TCP timeout is about retransmits with backoff and how many is tried by the winsock stack. The default of these initial packet exchanges is 21 seconds with 2 retransmits (3 overall SYNs) and initial RTO of 3 (3 + 6 + 12). So that explained the timeouts we saw during periods of high network congestion.
There is no API exposed in WinHTTP to control those low-level TCP timeouts. And thus it doesn't make any sense to have a 'ConnectTimeout' on the WinHttpHandler class.
Commit migrated from https://github.com/dotnet/corefx/commit/ee0b3a76c8c57ef80d1d53a16deb5b0bc6b46793
Building on the current use of environment variables for passing in test settings, added a common test helper class to allow the http and websocket tests to access alternate test servers. This will help with load balancing and network latency issues which are causing occasional timeouts in CI tests. This will also allow developers to run their own version of the Azure test endpoints. Consolidated the current environment variables used and standardized on a naming format.
Fixesdotnet/corefx#2383.
Commit migrated from https://github.com/dotnet/corefx/commit/3603ed2578220f0ecb2f101324e04acb80fa3196