Commit Graph
580 Commits
Author SHA1 Message Date
stephentoub cb6ce9a1b3 Remove delegate allocation from WinHttpHandler.SendAsync
Each SendAsync call was allocating a new delegate for StartRequest.


Commit migrated from https://github.com/dotnet/corefx/commit/7c553bc3e68736d1fec2f82d87e7cb4178cbcf14
2015-09-19 20:03:09 -04:00
David Shulman 138469108b Disable SafeHandle leak checking in WinHttpHandler Unit Tests
Addresses issue dotnet/corefx#3312.


Commit migrated from https://github.com/dotnet/corefx/commit/b30b39707bfc9359c46e4749552f879ae37fcf13
2015-09-19 08:16:11 -07:00
Alexander Köplinger 3e20a867b2 Update build to use DNX beta7 instead of beta5
The corefx build used an older beta5 version of DNX which hardcoded the path to bash in dnu, breaking the build on FreeBSD.
Updating DNX to the latest "stable" beta7 release fixes this.

After updating I noticed a few test projects didn't build anymore as they were missing some dependencies in project.json, added those.

Fixes dotnet/corefx#3173


Commit migrated from https://github.com/dotnet/corefx/commit/6df77fdbb6cf8e0d35a3074bb325f7810085daa3
2015-09-16 02:12:26 +02:00
David Shulman 9d7de1b937 Merge pull request dotnet/corefx#3096 from davidsh/winhttphandler_leaks
Improve WinHttpHandler and SafeWinHttpHandle reference counting logic

Commit migrated from https://github.com/dotnet/corefx/commit/407ea6bac4200608d86c91b6e32b925d6a3580e0
2015-09-09 11:52:42 -07:00
David Shulman e0c3d074dd Improve WinHttpHandler and SafeWinHttpHandle reference counting logic
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
2015-09-08 08:27:04 -07:00
Alexander Köplinger 919950a89d Use SR.Format instead of string.Format
See https://github.com/dotnet/corefx/pull/3078.
This applies the same fix to all other places in the codebase.


Commit migrated from https://github.com/dotnet/corefx/commit/d2bb418da30f27f4ef4203f46f7bd3b57a9433a0
2015-09-04 00:03:05 +02:00
David Shulman ad147f22f2 Fix error handling in WinHttpHandler StartRequest
Addresses dnu restore exception 2547
https://github.com/aspnet/dnx/issues/2547

- Fix a code path where `requestHandle` could be `null`.
- Add unit test to simulate this error code path.
- Simply use of Assert.ThrowsAsync<T>


Commit migrated from https://github.com/dotnet/corefx/commit/11d048b399788c26268819eef962b130ecf472c8
2015-08-31 18:44:33 -07:00
David Shulman 34bd120067 Merge pull request dotnet/corefx#2524 from bbowyersmyth/NetRequests
Reduce HttpWebResponse header allocations

Commit migrated from https://github.com/dotnet/corefx/commit/366af5bad1e182c2d193fb7ef8cf90abe8fb4a17
2015-08-25 10:19:43 -07:00
Rajan Singh 680c39d776 Merge pull request dotnet/corefx#2810 from rajansingh10/myfeature
Moving shared default between winHttp & Unix Handler to a seperate common file

Commit migrated from https://github.com/dotnet/corefx/commit/e2e6dcc236c0c01463a1a43349be14761eabf442
2015-08-21 12:03:44 +05:30
David Shulman 94fd9ab990 [HIGH PRIORITY - Proposed fix to be included for ASP.NET Beta7]
This fixes a bug found with chunked uploads using custom content that repeatedly calls Flush() on the stream passed into SerializeToStreamAsync.

This bug was discovered by WCF tests and reported via GitHub: https://github.com/dotnet/corefx/issues/2897

It was a mistake to use the Flush() method on the stream to send the final terminating chunk for the upload since that method can be called by custom content via the SerializeToStreamAsync method. The typical use pattern is that depending on the actual streams involved, upper layer software typically can call Flush() one or more times when writing to a stream. The fix here is to simply leave Flush() as a no-op (which it basically is for the WinHttpRequestStream) and have an internal method to handle the writing of the final terminating chunk.

This fix is being checked into TFS instead of using a GitHub PR. The reason is that the tests for this need to use our current internal server that correctly echoes the request headers in order to verify 'Transfer-Encoding: chunked' was sent by the client. I tried to put this test into the current GitHub tests using the current "http://httpbin.org" test server, but I discovered that httpbin.org doesn't properly echo the request headers when 'Transfer-Encoding' is sent. Instead, it ends up replacing that header and sending back 'Content-Length' (even though we didn't send that in the request headers). We have a backlog work item to port our remaining ToF tests to GitHub over the next several weeks.

[tfs-changeset: 1516976]


Commit migrated from https://github.com/dotnet/corefx/commit/ac9e5d9426ce28216a9d49d0753c8790e7aac0d2
2015-08-20 16:53:43 -07:00
Rajan Singh 9b679bfb53 Moving shared default between winHttp & Unix Handler to a seperate common file
Commit migrated from https://github.com/dotnet/corefx/commit/756ed1131ced4649c6a23940b9707012ec1d2ff2
2015-08-17 13:03:42 +05:30
Eric St. John d7a0ae297b Update corefx packages to latest
Commit migrated from https://github.com/dotnet/corefx/commit/23f0b695bd162e0f665427c95180dc21931e5c70
2015-08-14 15:43:23 -07:00
Eric St. John 24877d3ce7 Move System.Net tests up to latest pre-release version
This change undoes the workaround from https://github.com/dotnet/corefx/commit/dotnet/corefx@5d9f9d4c6ea450366c7b70af6e6006a401284d14#diff-53766f09e26c8b4b422d2946d05c83a6


Commit migrated from https://github.com/dotnet/corefx/commit/ccdf7bb4a2a87de13f8dba69ac7a0df3818c69b1
2015-08-14 10:21:53 -07:00
Eric St. John 77309d4821 Update the version of all assemblies
This change updates the assembly versions of all of the corefx assemblies
as needed after we shipped stable versions.  Assemblies with API differences
get a minor version bump.  Assemblies with only bugfixes get a build version
bump.

In order to facilitate this I had to update the reference assemblies, so I took
the opportunity to port them all to the open.

[tfs-changeset: 1514419]


Commit migrated from https://github.com/dotnet/corefx/commit/40723b795917f2e98b64d45c17effb2546dd0cae
2015-08-13 17:07:57 -07:00
Guillermo Rangel 5057608a6d Fixing potential integer overflow in arithmetic operation (+).
Using a - operation instead of + so we don't need casting to long.


Commit migrated from https://github.com/dotnet/corefx/commit/e537fb7c9e24d608ab5c85e52e39ddfcbbf5f41b
2015-08-12 14:39:26 -07:00
Guillermo Rangel ff81931a13 Fixing CancellationToken not propagating properly and adding some Tests to verify it.
Addressing Feedback in GitHub

Renaming TestHandler to SendAsyncWinHttpMockHandler and adding missing spaces.

Added missing line in json file to use System.Runtime.InteropServices.RuntimeInformation.


Commit migrated from https://github.com/dotnet/corefx/commit/e76774df88b497107e8289fce314ea149abc7811
2015-08-11 13:58:39 -07:00
Eric Mellino 66969e748b Re-lock dependencies with latest xunit
Commit migrated from https://github.com/dotnet/corefx/commit/795cbc75f8e167047a7c19cd7e21e99b9b9f4308
2015-08-03 16:40:33 -07:00
Eric Mellino 219af47e0c Update test dependencies
Fixes all test warnings about 'different versions of the same dependent
assembly'


Commit migrated from https://github.com/dotnet/corefx/commit/b84f53f744ba0418255cbe471b783dde2a700a8e
2015-08-03 13:44:34 -07:00
Eric Mellino c0015fc582 Move all tests to latest xunit beta
Commit migrated from https://github.com/dotnet/corefx/commit/7c12b0120834f92d5c591124f692ea1b64c6a877
2015-08-03 11:27:48 -07:00
ericstj a419b9c68f Move System.Net tests back to pre-release versions temporarily to fix missing SecureString
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
2015-08-02 09:49:36 -07:00
Eric St. John 47aaf9fcf8 Use stable package dependencies and move our packages to post-stable versions
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
2015-07-31 15:47:51 -07:00
dotnet-bot d47f4c3abf Initial commit of System.Net.WebSockets.Client.
Commit migrated from https://github.com/dotnet/corefx/commit/2f2fae24846c40bc588625b47ec12f43ac323612
2015-07-27 14:41:34 -07:00
Bruce Bowyer-Smyth b8a60af105 Avoid StringBuilder creation for every response header, remove ToUpperInvariant allocation
Commit migrated from https://github.com/dotnet/corefx/commit/82dbecf9e081eaa3532d66055386b28ee970a608
2015-07-25 16:45:26 +10:00
stephentoub 1b6ae21013 Avoid a closure/delegate allocation in WinHttpHandler
One-line change to avoid a closure and delegate allocation on each call.


Commit migrated from https://github.com/dotnet/corefx/commit/2bddf6d0ce8576256845f0774b546fb9d819c3f6
2015-07-23 23:20:02 -04:00
David Shulman c1a17cc36c Fix proxy authentication handling during redirects
Reference issue dotnet/corefx#2168


Commit migrated from https://github.com/dotnet/corefx/commit/826d302b25ab445f32d8e24bfdcfcd7d5d915073
2015-07-23 15:20:39 -07:00
David Shulman f5e46293c1 Refactor WinHttpHandler tests for multiple test projects
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
2015-07-17 14:16:49 -07:00
Chad Nedzlek f6d0863a6d Update locks
Commit migrated from https://github.com/dotnet/corefx/commit/f9dd1c3d27d95ab7b6f805a63ad64a47972dfdfc
2015-07-10 14:53:21 -07:00
Chad Nedzlek b0209bda9a Fix non-beta versions
Commit migrated from https://github.com/dotnet/corefx/commit/30f67f8af2d2a2f76a307c6aa4fbce7afc55abee
2015-07-10 14:48:05 -07:00
David Shulman 946476a75e Improve security of AutomaticRedirection options for HttpClientHandler/WinHttpHandler
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
2015-07-07 08:32:37 -07:00
dotnet-bot c07d246c4d Initial open source of WinHttpHandler
Commit migrated from https://github.com/dotnet/corefx/commit/bbe092e0d2edad89df1e4dfc2fb7cfdc4656f3a1
2015-06-26 16:09:07 -07:00