Commit Graph
701 Commits
Author SHA1 Message Date
David Shulman 5bed169f64 Fix WinHttpHandler session handle initialization
A test running on Windows 7 was doing multiple parallel requests using the same HttpClient but throwing an unexpected winHTTP error. The problem only occurred on Windows 7 because the proxy initialization code in WinHttpHandler is different for that platform. In general, there is only one session handle created per handler and it is shared with multiple requests. The "init once" logic was faulty because it was setting the `_sessionHandle` field too early before everything was init'd. In addition, this exposed another bug where the session handle options were repeatedly set for each request even though they should only have been set once.

Fixed up the EnsureSessionHandleExists method to do the proper initialization. Also added more tracing.

Fixes dotnet/corefx#7085


Commit migrated from https://github.com/dotnet/corefx/commit/e9cacdcaef8a09c236de3362fa62429d80b6ecc6
2016-03-23 14:17:56 -07:00
stephentoub 0de8ee2b33 Update packages to rc3-23923
Commit migrated from https://github.com/dotnet/corefx/commit/123180cde4aadbed151ffbc00c09b85b7532da68
2016-03-23 11:56:57 -04:00
stephentoub b60997fa74 Update packages to rc3-23921
Commit migrated from https://github.com/dotnet/corefx/commit/3eb508d41d476e4ca0c74d106584c7a7f0d51a17
2016-03-21 12:10:10 -04:00
stephentoub 15713c4b05 Dispose of X509Certificate used in WinHttp server callback
Commit migrated from https://github.com/dotnet/corefx/commit/ef46cce05c310534aad268188c94994c2f68e262
2016-03-21 09:04:08 -04:00
Jon Hanna 1c58a2a42a Fix multiple typos [5]
Commit migrated from https://github.com/dotnet/corefx/commit/00a0871c5cc4ff6af7f036946eef48644ed1e27d
2016-03-20 19:15:44 +00:00
Eric St. John 6aeccb0bae Fix tests to restore using the latest packages
We removed the lifting from the lineup so tests should reference the
latest packages in order to ensure an implementation is available.

The latest pacakges exclude implementation dependencies so I needed to
add these to projects that were depending on them coming in transitively.


Commit migrated from https://github.com/dotnet/corefx/commit/bef9061fd1238adf47b864d8924d121e4134465b
2016-03-19 08:01:11 -07:00
Eric St. John ff75367f93 Update packages to rc3-23918
Commit migrated from https://github.com/dotnet/corefx/commit/d3d217b2ab336b862c27a3e605e32dc0c0a6d472
2016-03-19 08:01:09 -07:00
Eric St. John 12e01eeda2 Add dummy impl for platform specific API
This adds dummy implementations for platform specific API.  The
implementation assemblies throw PlatformNotSupported for all methods.

This will satisfy NuGet's guardrails check and also let folks compile
against these assemblies and load them at runtime without JIT failures.

We will not be placing these packages in any of the shared-framework
layouts, nor should any of these ever be depended on by CoreFx
libraries.  But we will provide them to enable folks to write platform
lightup code without having to worry about using reflection or guarding
calls in separate methods disabling JIT inlining.

These assemblies are marked with AssemblyMetadata("NotSupported",
"True"), so that future dev-time tooling can detect them and warn/error
in the case of accidental dependence on platform specific API.

One notable difference is
System.Runtime.InteropSerivices.WindowsRuntime: this assembly was
previously part of portable profiles and implementation exists in
mscorlib.  For this we will forward to mscorlib on all platforms and it
is up to mscorlib to determine implementation (throw vs noop).
Fixes https://github.com/dotnet/corefx/issues/6684

Other platform specific contracts that have been excluded:
System.IO.IsolatedStorage: currently only supported for netcore50 so no
need to address this problem for x-plat.
System.Runtime.WindowsRuntime & System.Runtime.WindowsRuntime.UI.Xaml:
both are WinRT specific and not exposed in any PCL profiles that we
expect folks to use with x-plat NET core.


Commit migrated from https://github.com/dotnet/corefx/commit/b12b5604c442c13b983f530e5bccfc0867f160cf
2016-03-17 14:21:08 -07:00
stephentoub 1cbe15bf38 Query for the right proxy creds in HttpClient
Both the WinHttp and libcurl implementations are using the target Uri to lookup the right proxy credentials rather than using the proxy's Uri.


Commit migrated from https://github.com/dotnet/corefx/commit/d0cc5116a9906834f5ebd1813c9b9eed68ea054b
2016-03-17 10:34:06 -04:00
David Shulman a592a0b661 Address PR feedback
Commit migrated from https://github.com/dotnet/corefx/commit/4c8bd342f9e3ed7eb05dc51f115e40a94c5e3325
2016-03-15 10:10:22 -07:00
David Shulman 7ea6f917d6 Optimize WinHTTP notification callbacks
Modify WinHttpHandler and WinHttpWebSocket notification callbacks to only receive those notifications that are actually being used in the status callback. This will improve performance.

Fixes dotnet/corefx#5036


Commit migrated from https://github.com/dotnet/corefx/commit/e7e993cb8caaea9255d1babae6afd5f8ce5db680
2016-03-15 10:06:40 -07:00
David Shulman e0781372ea Address PR feedback
Commit migrated from https://github.com/dotnet/corefx/commit/5441deab3daaa92fa5bbcfdf4eb3c5b3bce75891
2016-03-14 09:53:16 -07:00
David Shulman 26901aeb5b Fix WinHttpHandler proxy discovery behavior
In order to support WindowsProxyUsePolicy.UseWinInetProxy, WinHTTP provides the WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY option. This allows for reading the per-user registry settings to determine how to find a proxy for a given url. This includes using WPAD protocol to find and execute a Javascript PAC file. The WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY only works on Windows 8.1 and above. For Windows 7 and Windows 8, we have to manually do the work and the WinInetProxyHelper class provides for that by calling various WinHTTP APIs.

This fix is about having the AUTOMATIC_PROXY behaviors work the same whether done automatically by WinHTTP or manually using the WinInetProxyHelper class. In general, errors processing the auto discovery logic should be ignored and the proxy settings should fallback to manual settings if present in the registry.

This is difficult to test in an Xunit test since registry settings need to be changed as well as recycling the "WinHTTP Web Proxy Autodiscover Discovery Service" since it caches PAC file processing. So, this was tested manually for now and additional traces were added to the WinInetProxyHelper class.

Fixes dotnet/corefx#6011


Commit migrated from https://github.com/dotnet/corefx/commit/25ebb1bff1526bbc81d622ba7fc7749181c458fa
2016-03-13 17:46:38 -07:00
David Shulman 420449a472 Fix WinHttpHandler when no proxy creds after 407 response
We were getting an assert if we had an authenticating proxy but didn't have any credentials to send. After the initial 407 was received from the proxy, we then tried to set credentials for a retry. But since we didn't have any, we triggered an assert in SetWinHttpCredential.

The fix is to check for null credentials after getting the 407 response. If there are no credentials, then we end the retry loop with the final 407 status code.


Commit migrated from https://github.com/dotnet/corefx/commit/89966ef37a1269471069c2ee14cdb6af51d8a707
2016-03-10 19:18:38 -08:00
stephentoub d5e591e45a Update packages to rc3-23910
Commit migrated from https://github.com/dotnet/corefx/commit/ab3948bfab039aac2afc1b521883425a171b982d
2016-03-10 09:37:40 -05:00
Justin Van Patten 0d18ce8a1d HttpClient should not miss Set-Cookie response headers
Recent changes due to PR dotnet/corefx#3199 caused `HttpClient` on Windows to miss
`Set-Cookie` response headers when one of the header values was large
enough to cause `WinHttpQueryHeaders` to fail with
`ERROR_INSUFFICIENT_BUFFER` and advance the index.

This commit addresses the regression, by always setting the index
back to the index we want to retrieve.

Added a new test to validate this change.

Fixes dotnet/corefx#6737.


Commit migrated from https://github.com/dotnet/corefx/commit/f7e9f00aba800d2ea63e040deafcc7ee220331fc
2016-03-09 02:35:42 -08:00
Eric St. John 8cba463a08 Update crypto package dependency versions
System.Security.Cryptography.Algorithms, Cng, and X509Certificates are
now 4.1.0.  Update dependencies to ensure we get the right build.


Commit migrated from https://github.com/dotnet/corefx/commit/6e3e29dbec3705094a539b6b2dc863c5a8ee270c
2016-03-08 21:40:47 -08:00
Eric St. John f4d3d8121e Undo X509Certificates workarounds
Fixes https://github.com/dotnet/corefx/issues/6718

Previously NETStandard1.3 packages couldn't consume X509Certificates
due to a missing reference assembly.  That's been fixed so we can undo
the workarounds.


Commit migrated from https://github.com/dotnet/corefx/commit/13f225a650f40b5661cccc93985facb1b07f3786
2016-03-08 08:46:51 -08:00
Eric St. John 04a73fbed6 Update packages to rc3-23908
Commit migrated from https://github.com/dotnet/corefx/commit/86a230845c4f1840dcb9b52165c6976fad5b5868
2016-03-08 08:46:50 -08:00
Stephen Toub ab2ef9d0fd Merge pull request dotnet/corefx#6727 from davidsh/blank_statusdescription
HttpResponseMessage.ReasonPhrase should not be null

Commit migrated from https://github.com/dotnet/corefx/commit/3da7a023a2cf89c0a980a6c5cde25b67be530f68
2016-03-07 20:40:09 -05:00
David Shulman fe95f82188 Address PR feedback
Commit migrated from https://github.com/dotnet/corefx/commit/4899e455c04c65607dc8e8022358c9b01fccc2b9
2016-03-07 15:33:10 -08:00
Eric St. John 65d3d63e3e Workaround no NETStandard1.3 support in X509 pkg
Switches from package to project reference for projects that consume
X509Certificates and target NETStandard1.3.  Package refefences were
added to other crypto contracts to satisfy the closure walk done during
target framework validation.

Remove all of this when fixing https://github.com/dotnet/corefx/issues/6718


Commit migrated from https://github.com/dotnet/corefx/commit/4c7720dee1897bddd69be267d84261530a136c87
2016-03-07 13:00:12 -08:00
David Shulman 1e120fdd63 HttpResponseMessage.ReasonPhrase should not be null
Recent changes due to PR dotnet/corefx#3199 caused the `HttpResponseMessage.ReasonPhrase` property to be a null string if the HTTP server response only contained a statuscode but no description on the status line. The existing .NET Framwork behavior is to have empty string as the property value in that case.

Added a new test to validate this change.

Fixes dotnet/corefx#6721.


Commit migrated from https://github.com/dotnet/corefx/commit/19ec320403cd53ad0cba75c69a1a2c027ed867d5
2016-03-07 12:23:04 -08:00
stephentoub 38f7d19954 Update packages to rc3-23907
Commit migrated from https://github.com/dotnet/corefx/commit/baed539ebb753fefc91da9870ddeee72df0a6e14
2016-03-07 10:12:40 -05:00
stephentoub f3434408bc Update xunit.netcore.extensions to 00187
Commit migrated from https://github.com/dotnet/corefx/commit/3cfd81e7369628d052da6367b28c6f5b5839f55d
2016-03-03 22:06:40 -05:00
stephentoub 9b4473ede7 Upgrade package versions to rc3-23901
Commit migrated from https://github.com/dotnet/corefx/commit/55246a7fc60807d021fded5e333784956a662a51
2016-03-02 07:40:12 -05:00
Kamil Rytarowski 24a9cc2272 Mark disabled tests on Linux&OSX also disabled on NetBSD
Commit migrated from https://github.com/dotnet/corefx/commit/a9c7155de21cf11ff270a0f9d89cfc7cb82ff2ec
2016-03-01 02:48:19 +01:00
Eric St. John 19554adc35 Update buildtools and change validation framework
Update BuildTools to 1.0.25-prerelease-00180

Change validation framework moniker from dnxcore50 to
netstandardapp1.5.


Commit migrated from https://github.com/dotnet/corefx/commit/7c50768be0a2008480aa22ddb8038fdcb0e8039b
2016-02-29 14:43:26 -08:00
Eric St. John afdeaf78b0 Remove use of DNXCore from packages
This changes every package that used the DNXCore50 moniker to use a
NETStandard moniker instead.


Commit migrated from https://github.com/dotnet/corefx/commit/6008326984df7bddff751d0fec678ee29d821a59
2016-02-29 14:43:25 -08:00
Pallavi Taneja 3f93bc1c13 Fix packages issues due to the update
Commit migrated from https://github.com/dotnet/corefx/commit/9b8403541bfbd4b1956944723b68167ad12fbf29
2016-02-29 13:09:16 -08:00
Pallavi Taneja 38e2f4de64 Update the packages
Commit migrated from https://github.com/dotnet/corefx/commit/be7151b45a54577c2e28c56977408d7d61ed0ea9
2016-02-29 13:09:16 -08:00
David Shulman 855884a920 Release pinned buffers correctly for WinHttpHandler, WinHttpWebSocket
Both WinHttpHandler and WinHttpWebSocket use pinned buffers for receiving and sending data. The pinned GCHandle was being freed during the dispose of the WinHttpHandler or WinHttpWebSocket objects. The problem is that the buffer should not be unpinned until the async operation is done. It's possible for any async operation to be in flight (and where native code uses the buffer) when the object is explicitly or implicitly disposed.

This fix moves the ownership of the pinned GCHandle to their respective state objects (WinHttRequestState, WinHttpWebSocketState). These objects are strongly rooted and are not released until all async operations are completed and the WinHTTP handles are fully closed. That makes these state objects a safe place to own and free the pinned buffers.

Fixes dotnet/corefx#2508 and dotnet/corefx#6142


Commit migrated from https://github.com/dotnet/corefx/commit/a6eee4cec6bf663a030c8cd41f7a3fc3349b01e3
2016-02-28 08:06:32 -08:00
Stephen Toub 834f1fb44a Merge pull request dotnet/corefx#6389 from stephentoub/arg_names
Fix use of nameof with ArgumentException

Commit migrated from https://github.com/dotnet/corefx/commit/581d8ec923f57a33c43f3fbccdf47cd527010c47
2016-02-25 17:21:44 -05:00
David Shulman ccb02fce56 Fix memory leak caused by cycle reference in WinHttpRequestState
The fix made in PR dotnet/corefx#6285 for this memory leak turned out to be insufficient. The request handle object for the stream (SafeWinHttpHandle) was part of the strong root chain in WinHttpRequestState. And even when the WinHttpResponseStream object was finalized (implicit Dispose), the request handle was not finalized and thus leaks were happening.

To address this, the request handle object reference is now cleared from the WinHttpRequestState object (along with other object references) once the WinHttpResponseStream is created. WinHttpResponseStream then gets passed the request handle reference. Then normal finalizer rules can apply to both WinHttpResponseStream and the request handle. Once the request handle gets disposed (via finalizing), native WinHTTP will send a final status callback (HANDLE_CLOSING) and that is how the state object will then get unrooted and freed.

Tested this fix with WCF streaming scenarios and used WinDBG to verify the heaps.

There are future plans to improve this code via refactoring as part of dotnet/corefx#2501.

Fixes 5927.


Commit migrated from https://github.com/dotnet/corefx/commit/f2b47770d9014423ab830285b0fee47b75c44c02
2016-02-25 09:55:05 -08:00
Stephen A. Imhoff 811f903c18 Fix use of nameof with ArgumentException
Correct instances of new "ArgumentException(nameof(..." so names are in the correct parameter.  Where possible, I chose the resource string I felt best fit the situation.  Otherwise, I created a new entry (I'm assuming there's some extra work that needs to be done there, but don't know what it is offhand).


Commit migrated from https://github.com/dotnet/corefx/commit/368fdfd86ee3a3bf1bca2a6c339ee590f3d6505d
2016-02-25 10:35:40 -05:00
Eric St. John 5af200cd50 Rename "dotnet" to "NETStandard"
Fixes https://github.com/dotnet/corefx/issues/5707

We are changing the .NET packages to no longer use the ‘dotnet’, ‘dotnet5.x’, and ‘dnxcore50’ monikers.  This is thee first stage of the change for dotnet->netstandard.

The replacements are as follows

Old moniker | New moniker
----------------- | ------------------
dotnet5.x | netstandard1.y  (where y = x -1)
DNXCore50 | netstandardapp1.5
dotnet | netstandard1.3

To prepare for this change you can do the following to your project.json.  This change will require a recent build of NuGet or dotnet.exe and can be done prior to consuming the packages with the breaking change.  These packages will not work with DNX.

For a project targeting dotnet5.6
```
    "frameworks": {
        "netstandard1.5": {
            "imports": [ "dotnet5.6" ]
        }
    },
```

For a project targeting dnxcore50
```
    "frameworks": {
        "netstandardapp1.5": {
            "imports": [ "dnxcore50", "portable-net45+win8" ]
        }
    },
```

[tfs-changeset: 1578321]


Commit migrated from https://github.com/dotnet/corefx/commit/4435f9f2776ae007e05f4454675e56cf76a51975
2016-02-23 20:18:17 -08:00
David Shulman cc3124f083 Merge pull request dotnet/corefx#6291 from davidsh/readasync_fix
Response stream reads should return error for insufficient data

Commit migrated from https://github.com/dotnet/corefx/commit/0a0ea7fe57876ef47188dfe8bd76fae00e48f8e7
2016-02-21 18:03:10 -08:00
David Shulman 29ffaec8ad Address PR feedback
Commit migrated from https://github.com/dotnet/corefx/commit/6b4519800e1db707556a6730dc178e446e0836ba
2016-02-21 16:53:46 -08:00
David Shulman 7bdf953b91 Address PR feedback
Commit migrated from https://github.com/dotnet/corefx/commit/6e898758c6c03c44234ccc3ae398c432c97f5ff9
2016-02-21 16:45:39 -08:00
David Shulman 19962646b8 Response stream reads should return error for insufficient data
WinHttpResponseStream was not tracking the amount of data read when the response used 'Content-Length' semantics. So, if the amount of bytes read from the server was less than expected, we did not return an error. This was different behavior than .NET Framework.

Fixed WinHttpResponseStream so that it will track the total number of bytes read and compare it to the expected number of bytes if using 'Content-Length' semantics. Note that we don't do this checking if the HTTP request is a HEAD request. That is because the definition of that HTTP verb is to return headers "as-if" it was returning a real response body. So, the 'Content-Length' might be set but there is no response body for a HEAD request.

For cases of using 'Transfer-Encoding: chunked' semantics for the response body, there is already error checking at the lower HTTP layer in WinHTTP.

Fixes dotnet/corefx#6231.


Commit migrated from https://github.com/dotnet/corefx/commit/7f5d6b643996306062836a17ddad643fd7e40ff2
2016-02-21 15:36:38 -08:00
David Shulman 53aa563b67 Fix WinHttpHandler memory leaks
The WinHttpHandler was leaking a lot of objects in cases where an explicit Dispose was not done for the various HttpResponseMessage related objects. It was leaking because there was a cycle between the strong GCHandle of WinHttpRequestState and the objects contained within it.

To break the cycle, we now clear out object references within WinHttpRequestState that are no longer needed once the SendRequest phase is completed.

There was also a leak of a pinned GCHandle and related memory in WinHttpResponseStream. The free'ing of that allocated GCHandle was done in the Dispose(bool disposing) method. However, it wasn't being called when disposing=false (i.e. a finalizer). Since it is a pinned GCHandle, it needed to be freed in all cases.

Fixes dotnet/corefx#5927.


Commit migrated from https://github.com/dotnet/corefx/commit/a38ee461d2d93cc220953b3b6c4b405b188f6965
2016-02-21 11:41:42 -08:00
Christopher Costa b7275a6e29 Merge branch 'master' of https://github.com/dotnet/corefx into open_pkgs
Commit migrated from https://github.com/dotnet/corefx/commit/7df55caaad1d1e21866ec31b0e7161db9ae2179c
2016-02-19 14:21:24 -08:00
Justin Van Patten 0c5d4b54f3 Use nameof with MemberData tests
Commit migrated from https://github.com/dotnet/corefx/commit/2965a16a7660f90f45fbd880a430d7c5e9e086a0
2016-02-19 11:16:20 -08:00
Christopher Costa 8d91794cf8 Merge branch 'master' of https://github.com/dotnet/corefx into open_pkgs
Commit migrated from https://github.com/dotnet/corefx/commit/6c7226985ebea63f36d3d24e4c65e331a2e277c1
2016-02-19 10:56:24 -08:00
dotnet-bot b32ddb5d98 Deploy nameof throughout corefx in MemberData
Commit migrated from https://github.com/dotnet/corefx/commit/9c3156b9ada06b8e58ac53d48fc303500bf3e476
2016-02-18 23:58:15 -05:00
dotnet-bot 3184718282 Deploy nameof throughout corefx in exception construction
Mostly automated replacement of parameter name string literals with corresponding usage of nameof.


Commit migrated from https://github.com/dotnet/corefx/commit/396b41ddec99d01505c1bc4fa02fb0f0c5844990
2016-02-18 23:58:06 -05:00
David Shulman 52476494de Merge pull request dotnet/corefx#3199 from justinvp/winhttphandler_parseresponseheaders
Reduce allocations when parsing response headers in WinHttpHandler

Commit migrated from https://github.com/dotnet/corefx/commit/35f7ef05a8022358ec435152e7099d8263a4422a
2016-02-18 15:52:45 -08:00
Christopher Costa d95b14a3c4 Merge branch 'master' of https://github.com/dotnet/corefx into open_pkgs
Commit migrated from https://github.com/dotnet/corefx/commit/b70432898b7a00edb3303c0fbf4a1b98ebe442b4
2016-02-18 10:28:54 -08:00
stephentoub 95d7cc7534 Update packages to rc3-23818
Commit migrated from https://github.com/dotnet/corefx/commit/380a2ebf4a498f9ab0a819c71d8717377e601bfb
2016-02-18 07:28:09 -05:00
Justin Van Patten 1418f94145 Address PR feedback
Commit migrated from https://github.com/dotnet/corefx/commit/0aab2ac0feffe1ff3adce05bda7bf6a0e9a8baac
2016-02-17 11:07:14 -08:00