This PR mainly addresses "handle leaks" dotnet/corefx#2963, dotnet/corefx#2762, dotnet/corefx#2793. In investigating the leaks, I discovered that our use of the SafeHandle pattern was not quite right. Native Windows WinHTTP handles wrapped by SafeHandle need additional lifetime management protection to preserve parent-child relationships. Closing the parent handle too early will invalidate the child handle. So, added a SetParentHandle() method to SafeWinHttpHandle to protect against this. This also simplified the passing of handles to the WinHttpResponseStream class.
After adding leak detection, I discovered a race condition caused by an CancellationToken.Register that should not exist in WinHttpHandler.
This inadvertently provided a way for the awaited SendAsync() task to return back to the caller even though the StartRequest() method is still
running.
Added unit tests to validate the behavior assumptions and to track leaks in the WinHttpHandler logic.
This change does not affect the SafeWinHttpHandleWithCallback class that is used by System.Net.WebSocket.Client. But that class is incorrectly using the SafeHandle pattern w.r.t. Dispose() and I will be fixing that in a later PR.
Commit migrated from https://github.com/dotnet/corefx/commit/a75ec027daa53114c788464878e2947ae7d5a65e
The stable versioned packages use an older codebase currently than the latest pre-release.
That codebase is still using SecureString in System.Private.Networking, but the dependency
was omitted since crypto is still pre-release but networking had to be marked stable for UWP.
This missing dependency was causing tests to fail.
Rather than just list the dependency I am moving these tests back to pre-release packages
for the System.Net contracts, since System.Net packages are under active development
it is better to have the tests running against latest than the stable bits.
Once we have newer versions published we'll update these tests to use those.
Commit migrated from https://github.com/dotnet/corefx/commit/5d9f9d4c6ea450366c7b70af6e6006a401284d14
This change modifies the build to consume the stable version where available.
This disables building the dowlevel packages since we shipped them once as stable and we're done.
From here on out, we'll only build the latest version (except for a servicing event, which would
be handled by syncing to a hash).
I can't rev the package versions in the normal way yet (by modifying the assembly version of the contents)
because that turned out to be too big of a problem to tackle in this change. Instead I added a
parameter to the task that calculates package versions to do the rev for anything that was
stable, but only when building the package itself, not when calculating the dependencies.
This has the downside of not permitting a dependency on a incremented pre-release version if we've
shipped a stable version, but that is a small point in time problem until I can rev the assembly
versions.
[tfs-changeset: 1508664]
Commit migrated from https://github.com/dotnet/corefx/commit/ee1ec2891c7c65b46fa9dfb078636be503bb2a60
This change sets up the layout for having multiple test projects for
WinHttpHandler. It follows the current guidlines as well as working
within the BUILDTOOLS requirements of having ".Tests.csproj" for the
names of the projects.
Also, fixed up some cross-platform definitions in the solutions files
for Http and WinHttpHandler.
After this PR is done, we will be migrating a large set of http
functional tests to GitHub
Commit migrated from https://github.com/dotnet/corefx/commit/42d81c41175ab8832032a2a387b8dc58365604a9
As per the latest security review, this issue captures the following tasks in order to remove insecure automatic redirection of HTTPS -> HTTP in HttpClientHandler/WinHttpHandler. This will also match the current NETCore/NETNative behavior as well.
In general, the security guidance is to remove insecure patterns from new code/platforms. This helps the entire ecosystem become more secure while balancing the needs of app-compat.
1. Change the WinHttpHandler API surface to remove the AutomaticRedirectionPolicy enum 3-state value.
2. Change the name/type of the 'AutomaticRedirectionPolicy' property to 'bool AutomaticRedirection'. This matches the current Framework Design guidelines of fully spelling out words and the word pattern of the 'AutomaticDecompression' property.
3. The default for the AutomaticRedirection property will be true. This value means that all redirects will be followed automatically EXCEPT for https:// to http://. This behavior is different from .NET desktop where https:// to http:// redirects are also followed.
[tfs-changeset: 1498199]
Commit migrated from https://github.com/dotnet/corefx/commit/4c99b29d6718af2de6d5e53869c694054cae161b