Commit Graph
217 Commits
Author SHA1 Message Date
David Shulman 8e11e35537 Fix auto decompression behavior in Http handlers (dotnet/corefx#29903)
Fixed a few bugs in both WinHttpHandler and SocketsHttpHandler regarding the behavior of
'Accept-Encoding' request headers and automatic decompression of response body content.

On Windows 7, native WinHTTP doesn't support automatic decompression. That also means it doesn't automatically append 'Accept-Encoding' request headers. WinHttpHandler was relying on WinHTTP to add those headers. But it wasn't happening on Windows 7. So, now WinHttpHandler will make sure those headers are added if not already present. WinHttpHandler was also always decompressing content even when the encodings in the .AutomaticDecompression property didn't match.

SocketsHttpHandler had a different bug. It would make sure that the 'Accept-Encoding' headers were
present when .AutomaticDecompression was being used. But it wouldn't check for existing headers and duplicate encodings would be present in the outbound 'Accept-Encoding' request header.  I.e., it would end up with "Accept-Encoding: gzip, gzip".

In addition to fixing these bugs, I added more tests to both Http Functional and WinHttpHandler Unit
tests (which can simulate running on Windows 7 using the existing mocks).

Fixes dotnet/corefx#29747
Fixes dotnet/corefx#26991


Commit migrated from https://github.com/dotnet/corefx/commit/40ce4cb20270f731d7d826291e1edce8d1ce2c37
2018-05-25 14:48:26 -07:00
David Shulman e7ae16d343 Disable Http tests on UAP (dotnet/corefx#29803)
Many dozen of Http tests are failing on UAP test runs. This is not showing up during PR/CI
because the UWP leg only is building the product and test sources and not actually running
any tests. However, the test failures show up in Helix and also when run locally on a dev machine.

So, for now, I'm disabling some of these tests so that the inner and outer test runs will pass.

Contributes to dotnet/corefx#29802
Closes dotnet/corefx#27953

Commit migrated from https://github.com/dotnet/corefx/commit/3326f3f24dd083f0966c8f71c7d1e8c2caa1ddae
2018-05-20 09:33:35 -04:00
David Shulman bfad67798e Disable test on NETFX (dotnet/corefx#29743)
This newly added test was always failing in NETFX (Outerloop).

.NET Framework has always had a limitation and cannot resolve DNS names with Unicode since it is p/invoking into the 'A' and not 'W' version of the native APIs. The workaround for developers is to use punnyname for the DNS name.

This is currently being tracked with internal bug 125570.

Commit migrated from https://github.com/dotnet/corefx/commit/8ab4f2c1b3bddf79ea3d206a0fec8444f0af167a
2018-05-16 12:18:52 -07:00
Stephen Toub 25edfafe0e Fix TaskContinuationOptions => TaskCreationOptions in test (dotnet/corefx#29667)
Commit migrated from https://github.com/dotnet/corefx/commit/1b5782d29d18f96c20d26e5c8f2844f5d082c887
2018-05-11 18:44:31 -04:00
Caesar Chen f902f3ef5f Unify setting null CookieContainer behavior on HttpClientHandler (dotnet/corefx#29337)
* unify set null CookieContainer behavior

* address test issue, and address feedback

* disable a test


Commit migrated from https://github.com/dotnet/corefx/commit/e30a7494292f3e6e66c0d152ad3240fa1f6dc766
2018-05-03 14:32:32 -07:00
Stephen Toub d5ba24bff1 Several Http test fixes to hopefully improve test reliability (dotnet/corefx#29238)
- Add “Connection: close\r\n” response header in more cases where the loopback server explicitly closes a connection, and in particular where the client makes multiple connections.
- Change several Task.WaitAlls on paired tasks to instead use our WhenAllOrAnyFailed helper.

Commit migrated from https://github.com/dotnet/corefx/commit/cebcf436358600a4808656b142a74f57d1e8f6f0
2018-04-20 18:21:18 -04:00
Marco Rossignoli 20e05bb5cd Pass Uri.IdnHost to WinHttpConnect (dotnet/corefx#28849)
* pass IdnHost

* add manual functional test

* cleanup

* fix comment

* address PR feedback

* address PR feedback

* address PR feedback

* address PR feedback

* address PR feedback

* address PR feedback

* address PR feedback

* fix IPv6 IdnHost

* address PR feedback


Commit migrated from https://github.com/dotnet/corefx/commit/b2893f07cf61dae81d424dd676a0d903a36a10c2
2018-04-17 09:55:34 -07:00
Caesar Chen 7669319f3f SocketsHttpHandler: Add workaround for ipv6 LLA address (dotnet/corefx#28971)
* add workaround for ipv6 LLA address

* address comment

* fix comment


Commit migrated from https://github.com/dotnet/corefx/commit/0698997390ddc15abb375eba73a5d712ccdb8266
2018-04-13 17:34:32 -07:00
Caesar Chen 3aab539b89 Fix proxied ipv6 address request formatting and fix port handling for proxied IP address on SocketsHttpHandler (dotnet/corefx#28740)
* fix proxied ipv6 address request format and fix port handling for ip address

* address feedback

* change naming for test data


Commit migrated from https://github.com/dotnet/corefx/commit/18d685f3b1ed8fd22601fb0bce3eb928f1c4206f
2018-04-05 15:17:20 -07:00
Paulo Janotti 9365b6fb44 Re-enable PostAsync_RedirectWith307_LargePayload dotnet/corefx#23768 (dotnet/corefx#28828)
Fixes dotnet/corefx#23768

Commit migrated from https://github.com/dotnet/corefx/commit/28dcece5c5e7d30446ae90e027076722513b716f
2018-04-04 16:54:06 -07:00
Caesar Chen 109d0485aa disable test (dotnet/corefx#28789)
Commit migrated from https://github.com/dotnet/corefx/commit/e4521cbd572764f3a140366cce7b39402e1a14cc
2018-04-03 16:49:01 -07:00
Caesar Chen 0ffc020ac5 Fix ipv6 address format in Host header (dotnet/corefx#28578)
* fix ipv6 format in host header

* address feedback

* address feedback

* fix common case

* reduce allocation

* address feedback

* fix indexof issue

* disable on curlhandler

* revert to simple fix

* address feedback and add comment

* address test issue, enable on curlhandler

* fix framework failure

* address feedback


Commit migrated from https://github.com/dotnet/corefx/commit/24889e293731f12b11f1205b641cd3e6cb3a3b90
2018-04-02 11:26:29 -07:00
Paulo Janotti c79012a5e5 CurlHandler is deadlocking like WinHttpHandler (dotnet/corefx#28587)
* CurlHandler is deadlocking like WinHttpHandler

This repros consistently for Release on High Sierra. Issue dotnet/corefx#27746 already tracks it.

* Adding a comment to clarify scope


Commit migrated from https://github.com/dotnet/corefx/commit/50d4e1ce620f26ec4aebe26c121a769fc8e724ab
2018-03-28 23:29:23 -07:00
Stephen Toub a6932f9f28 Ensure SocketsHttpHandler throws TaskCanceledExceptions instead of OperationCanceledExceptions (dotnet/corefx#28075)
To increase compatibility, as other handlers often throw the derived type instead of the base type, as a side-effect of how they were implemented.

Commit migrated from https://github.com/dotnet/corefx/commit/1f93d2a1c5f3bdeb8c091863236fe2071e5e66f5
2018-03-22 22:11:23 -04:00
Tomas Weinfurt 11740681f6 Improve HTTP proxy tests (dotnet/corefx#28048)
* refactor some proxy tests using new loppback server and new auth function

* feedback from reviews

* correct split() use. My local build did not fail for what ever reason

* disable ProxyExplicitlyProvided_DefaultCredentials_Ignored as it used to be

* refactor some proxy tests using new loppback server and new auth function

* feedback from reviews

* disable ProxyExplicitlyProvided_DefaultCredentials_Ignored as it used to be

* add test case for dotnet/corefx#27870

* skip new test on WindowNano

* add limit on Split() so it always splits to two tokens to avoid problems with : in the value

*  update Split() as it seems not all c# flavors has the righ overload

* small improvement on header split

* feedback from review


Commit migrated from https://github.com/dotnet/corefx/commit/b2a119950cb52dd744f84b552de1da2df07b937b
2018-03-22 18:01:15 -07:00
Stephen Toub 85e7f4e1aa Re-enable SocketsHttpHandler proxy test (dotnet/corefx#28186)
Commit migrated from https://github.com/dotnet/corefx/commit/089a8890c4f4d20dde6ee0ab6acfb3056f4887e6
2018-03-19 12:56:14 -04:00
Caesar Chen 9df60dc56a Make SocketsHttpHandler default Handler (dotnet/corefx#27821)
* set SocketsHttpHandler to default

* address feedback

* fix if check for 28002


Commit migrated from https://github.com/dotnet/corefx/commit/2b850f6fe5fd3171c2554da965cb07070e1d648e
2018-03-14 00:34:56 -04:00
David Shulman 0cb5ccfce2 Change behavior of SocketsHttpHandler for redirects (dotnet/corefx#28008)
When exceeding the max number of redirecs, .NET Framework will
not throw an exception. Instead, it will return the 3xx response.
This PR changes the behavior of SocketsHttpHandler to match.

Fixes dotnet/corefx#27285


Commit migrated from https://github.com/dotnet/corefx/commit/6e3a4143c221cba5f0f1b433b96477d24b7e9b02
2018-03-13 12:02:18 -07:00
Max Kerr 9485277884 CurlHandler: Remove Transfer-Encoding on redirect from POST to GET (dotnet/corefx#27988)
This fix removes the TransferEncoding header from a request when it is redirected from POST to GET.

Fixes: dotnet/corefx#27301

Commit migrated from https://github.com/dotnet/corefx/commit/94e4bc6e888825d2ad8f373c9bbc1b279608349b
2018-03-13 09:55:36 -07:00
Stephen Toub 700bbfd8dd Change CurlHandler to only request HTTP/2 over TLS (dotnet/corefx#27934)
* Change CurlHandler to only request HTTP/2 over TLS

* Add test that 2.0 request with http:// doesn't request Upgrade


Commit migrated from https://github.com/dotnet/corefx/commit/431475b8e5462fe7d6cf9e8d424d6624c08d6a3f
2018-03-12 12:46:09 -04:00
Stephen Toub a04cb1ef89 Disable hanging Proxy_UseSecureProxyTunnel_Success test on netfx (dotnet/corefx#27815)
Commit migrated from https://github.com/dotnet/corefx/commit/2660a4690f70c6278cbdb5564c3e62e51cc1a651
2018-03-07 09:52:11 -05:00
Geoff Kizer d02b3a1091 Merge pull request dotnet/corefx#27748 from geoffkizer/testplatformfixes
fix some conditional test logic related to SocketsHttpHandler

Commit migrated from https://github.com/dotnet/corefx/commit/0ad6968adb463fa1470ba4af09f270311c8a25a3
2018-03-05 19:31:46 -08:00
Geoff Kizer e83463359d fix some conditional test logic to ensure we're not disabling SocketsHttpHandler tests
Commit migrated from https://github.com/dotnet/corefx/commit/c2db57418b02cb03c2f27a38567d86436746a275
2018-03-05 14:22:55 -08:00
Stephen Toub 38cfd8b969 Add folded response header support to SocketsHttpHandler (dotnet/corefx#27727)
* Add folded response header support to SocketsHttpHandler

The feature is deprecated by RFC 7230, but some servers still utilize it, and if they do, SocketsHttpHandler currently fails (WinHttpHandler and the netfx handler both allow it, CurlHandler currently fails as well).  This commit updates the header parsing logic to allow for them.

* Address PR feedback


Commit migrated from https://github.com/dotnet/corefx/commit/dc355e96d61d98dee48a809571edda3c1c7e5525
2018-03-05 15:32:52 -05:00
Stephen Toub 7482b6a4b0 Expose and roll out ValueTask extensibility
This commit does several things:
- Exposes the new `ValueTask` extensibility model being added in coreclr.  The ValueTask-related files will separately be mirrored over to corefx to enable the netstandard build of System.Threading.Tasks.Extensions.
- Adapts all `Stream`-derived types to return `ValueTask` instead of `Task` from `WriteAsync`.
- Changes the new `WebSocket` `SendAsync` method to return `ValueTask` instead of `Task`, and updates the `ManagedWebSocket` implementation accordingly.  Most `SendAsync`s on `ManagedWebSocket` should now return a `ValueTask` that's either completed synchronously (no allocation) or using a pooled object.  It now uses the underlying transport's new `WriteAsync` overload that returns `ValueTask`.
- Switches more uses of `ReadAsync` and `WriteAsync` over to the new overloads, including in Process, DeflateStream, BrotliStream, File, HttpClient, SslStream, WebClient, BufferedStream, CryptoStream,
- Removed some unnecessary array clearing from various routines using ArrayPool (after the clearing was added we changed our minds and decided clearing was only necessary in very specific circumstances)
- Implements a custom `IValueTaskSource` in Socket, such that async receives and sends become allocation-free (ammortized).  `NetworkStream` then inherits this functionality, such that its new `ReadAsync` and `WriteAsync` are also allocation-free (in the unbounded channel implementations; we can subsequently add it in for bounded).
- Implements a custom `IValueTaskSource` in System.Threading.Channels, such that reading and writing are ammortized allocation-free up to one concurrent reader and writer.
- A few random things I noticed as I was going through, e.g. missing ConfigureAwait, some incorrect synchronization in tests, etc.
- Adds a ton of new tests, mainly in System.Threading.Tasks.Extensions, System.Threading.Channels, and System.Net.Sockets.


Commit migrated from https://github.com/dotnet/corefx/commit/6d1671b2cfcf130b7bc6c059bb0508073426532a
2018-03-02 09:56:25 -08:00
Geoff Kizer fe3585d9c5 Merge pull request dotnet/corefx#27220 from wfurt/ssl_Proxy2
support for CONNECT method in SocketHttpHandler 

Commit migrated from https://github.com/dotnet/corefx/commit/8e88850940605ef7d57cfc7b570bdf9bf2b8d822
2018-02-24 22:20:16 -08:00
Geoff Kizer 10fb7486c6 add issue number
Commit migrated from https://github.com/dotnet/corefx/commit/cc8db63f8688043306088b0057b05f69aa23e921
2018-02-24 14:52:34 -08:00
Geoff Kizer 9dba5b8340 revert change to existing redirect test and split into new test, disabled for WinHttpHandler
Commit migrated from https://github.com/dotnet/corefx/commit/edfa136cb9b003ac5575f9d1ad3e11dfbc147d76
2018-02-24 14:30:04 -08:00
Tomas Weinfurt 73922f6a6f update AllowAllCertificates so it works on systems with curl/nss. Disable test on Windows as it seems to cause some troubles.
Commit migrated from https://github.com/dotnet/corefx/commit/85756b823938ca5c5f6583d024a14363ad266f7d
2018-02-23 10:13:47 -08:00
Tomas Weinfurt 96d06a74f6 refactor Proxy_UseSecureProxyTunnel_Success little bit.
Commit migrated from https://github.com/dotnet/corefx/commit/9fa2b9ab41d361cb1e683a95585abd91f147c67b
2018-02-22 20:37:04 -08:00
Geoff Kizer 8df3174c2f Merge pull request dotnet/corefx#27377 from geoffkizer/redirecttestfix
add shutdown call to try to make redirect test more reliable

Commit migrated from https://github.com/dotnet/corefx/commit/59481ca56906713ef9e5e4890388f4cd2fe9c699
2018-02-22 15:57:26 -08:00
Tomas Weinfurt 3a42fc41f9 Merge branch 'master' of https://github.com/dotnet/corefx into ssl_Proxy2
Commit migrated from https://github.com/dotnet/corefx/commit/f909b9f95f099a197e7bb04479b930f0e596dfb7
2018-02-22 15:36:16 -08:00
Geoff Kizer 286740559c add shutdown call to try to make redirect test more reliable
Commit migrated from https://github.com/dotnet/corefx/commit/11a9368d1b1fbf0eca11406473e1e7f0c712ff3c
2018-02-22 12:03:09 -08:00
Stephen Toub 0365092b59 Disable SocketsHttpHandler's concurrent content sends (dotnet/corefx#27341)
* Disable SocketsHttpHandler's concurrent content sends

SocketsHttpHandler currently has some support for allowing request content sending to run concurrently with response content receiving.  However, we don't actually have a need for this, and there are a lot of subtleties that would need to be made robust, e.g. how to handle exceptions that occur concurrently in the sending and receiving.  For now, we're removing it.  Unless ExpectContinue is set to true, we just send the content before receiving the response, and if it is set, we start the send and then wait for it once we've received the final status code from the server.

* Address PR feedback


Commit migrated from https://github.com/dotnet/corefx/commit/fecb772f0607dc85afdb782eda1b42ddffcba61b
2018-02-22 14:58:19 -05:00
Stephen Toub 3c9dd1b90a Fix fragment handling in HttpClient (dotnet/corefx#27360)
* Fix fragment handling in HttpClient

SocketsHttpHandler isn't sending fragments, nor is it properly inheriting the fragment from the original request URI into the redirect location URI when the original URI had one and the redirect URI did not, even though RFC 7231 says it must.  This commit fixes that for SocketsHttpHandler.

WinHttpHandler also isn't handling this inheritance according to the RFC. It appears that the logic for WinHttpHandler would actually need to be changed in WINHTTP itself, or else WinHttpHandler would need to be changed to do the redirects itself.

Neither CurlHandler or NetFxHandler send fragments at all.

This commit also fixes the test to correctly compare the expected and actual Uris... apparently Uri equality doesn't factor in fragments, so they're first converted to strings.  It also updates the test to also validate that the server received the URI with the fragment included.

* Disable the fragments test on WinHttpHandler

Apparently it sometimes doesn't do the "right thing" even in other cases.


Commit migrated from https://github.com/dotnet/corefx/commit/a273be657f6666e333fd902965a56046d6f48018
2018-02-22 14:25:05 -05:00
Geoff Kizer c3645e3634 reconcile merge and fix curl issue
Commit migrated from https://github.com/dotnet/corefx/commit/4a779f45ac9475925a967a0b9ce3f9bd277fd041
2018-02-20 15:28:05 -08:00
Geoff Kizer cde1aa194a address review feedback and fix issue with redirect to GET handling
Commit migrated from https://github.com/dotnet/corefx/commit/37baaf29aabfd4bea4e1912b5a672a8c7af79c20
2018-02-20 15:28:05 -08:00
Tomas Weinfurt 220c12eeac use TestHelper.AllowAllCertificates for validation callback to pass test netfx
Commit migrated from https://github.com/dotnet/corefx/commit/df7eaef7f46fad8520c9ee7273b06eada2f6bdf6
2018-02-20 13:04:40 -08:00
Tomas Weinfurt a9426f88e7 update tests
Commit migrated from https://github.com/dotnet/corefx/commit/12d26820d9f85c6a64a6d753956bb41a32705056
2018-02-20 10:48:10 -08:00
Caesar Chen 987d73a579 Enable SendReceive_VaryingLengthBuffers_Success on Windows run (dotnet/corefx#27181)
* enable test on Windows run

* delete script

* disable test issue dotnet/corefx#27211

* disable test see dotnet/corefx#27217


Commit migrated from https://github.com/dotnet/corefx/commit/d3a69ff4448a0bd4df12e6af481898825c066c67
2018-02-16 16:03:46 -08:00
Stephen Toub b6b2da9344 Improve test coverage of SocketsHttpHandler (dotnet/corefx#27135)
* Improve test coverage of SocketsHttpHandler

Used code coverage information to write targeted tests to cover various uncovered paths in SocketsHttpHandler.  Along the way fixed a variety of issues relating to throwing the wrong exception type, a stack overflow due to an unexpected recursive call, etc.

* Address PR feedback

* Re-disable a test


Commit migrated from https://github.com/dotnet/corefx/commit/39677219aaeab8c6591b625ab2874acb17eaf4ef
2018-02-16 12:02:45 -05:00
Geoff Kizer bf6635fcfd add response generation overloads
Commit migrated from https://github.com/dotnet/corefx/commit/6943fc7c0e92359e6335a618f6ff5ee8402af4ac
2018-02-13 16:04:26 -08:00
Geoff Kizer c9a61b410b address PR feedback
Commit migrated from https://github.com/dotnet/corefx/commit/6ab005635528a03daa52ca727a4a74dcc0316830
2018-02-13 15:44:00 -08:00
Geoff Kizer b94eefba0f reorganize and cleanup some LoopbackServer code
Commit migrated from https://github.com/dotnet/corefx/commit/ec6a7215bb28a061d2357d8c3874447bc575132d
2018-02-13 15:43:59 -08:00
Max Kerr 717083f0d4 Clear Authorization Headers on Redirect (dotnet/corefx#26864)
When a user has added an Authorization header to a request via the HttpClient DefaultRequestHeaders Authorization field, ensure that header is stripped on redirect.

This change adds a method to strip Authorization headers that were set via the HttpClient DefaultRequestHeaders Authorization field, and calls that method on redirect. In addition, it adds a test to ensure that this behavior occurs as expected.

The new method ResetAuthRequestHeaders is based on the method ResetCookieRequestHeaders, which is used to reset cookie headers on redirect.

The issue also occurs in CurlHandler, but the fix is slightly different. Rather than remove the headers that have already been set, we can instead just skip them when copying over the new headers to the redirected request.

Fixes dotnet/corefx#26426

Commit migrated from https://github.com/dotnet/corefx/commit/7e6396b2bcb4d372b199cfb7b3b13e290c441124
2018-02-12 11:28:09 -08:00
Geoff Kizer 2927c099bf Merge pull request dotnet/corefx#26989 from geoffkizer/fixcookiehandling
SocketsHttpHandler: Fix some issues with cookie handling, and add cookie tests

Commit migrated from https://github.com/dotnet/corefx/commit/8cee267154ef9dc6dde7a76a828844a200437872
2018-02-11 18:23:50 -08:00
Geoff Kizer ef25741e58 consolidate cookie tests
Commit migrated from https://github.com/dotnet/corefx/commit/c20262c69a93449498d511014e9e69bad18f987a
2018-02-11 12:38:20 -08:00
Stephen Toub 5c894d6b17 Add SocketsHttpHandler check for TransferEncodingChunked w/o Content (dotnet/corefx#27040)
Commit migrated from https://github.com/dotnet/corefx/commit/bf5a3183bc901723ebe0bb3d178bec86cda57429
2018-02-11 12:19:03 -05:00
Stephen Toub 296015a364 Add more SocketsHttpHandler tests
Commit migrated from https://github.com/dotnet/corefx/commit/8cb4d130bc3e8151fc72fe9494787643c7b00c4b
2018-02-08 19:12:50 -05:00
Stephen Toub 89dfde815e Expose SocketsHttpHandler
- Renames ManagedHandler to SocketsHttpHandler
- Moves a bunch of files around accordingly
- Updates System.Net.WebSockets.Client to use SocketsHttpHandler directly
- Updates System.Net.Http's tests with a reflection-based rather than TLS-based method for instantiating an HttpClientHandler backed by a SocketsHttpHandler.


Commit migrated from https://github.com/dotnet/corefx/commit/852d40e723c849e8d0c486676d40332343e12ca5
2018-02-08 19:12:50 -05:00