Commit Graph
729 Commits
Author SHA1 Message Date
David Shulman bf75c2d777 Fix HttpClient redirection logic on UAP (dotnet/corefx#22702)
* Fix HttpClient redirection logic on UAP

This PR changes the implementation of sending requests in HttpClient for UAP when
dealing with redirection. In the past, we would let the WinRT layer handle auto
redirection logic. However, due to dotnet/corefx#9003, the cookies were getting lost on 3xx responses
since the .NET layer didn't see them. So, this PR implements the redirection ourselves.

One important part of redirection is that we need to drop credentials. The WinRT layer
did this for us. However, we are unable to use a single WinRT HttpBaseProtocolFilter object
since we need to remove the credential after the first redirect. So, we need to maintain
a second filter that uses no credentials and keep it in sync regarding all the other properties
of the primary filter.

With this PR, the behavior of other aspects (such as controlling max number of redirects, etc.)
now matches .NET Framework.  So, some tests were adjusted to remove the UAP specific behavior
checks.

Fixes dotnet/corefx#9003
Fixes dotnet/corefx#22191

* Disable test on Linux

* Address PR feedback

* Disable failing HTTP/2 test


Commit migrated from https://github.com/dotnet/corefx/commit/f2308f8db0679ac63e8e7eeac9d56cb035d6d9e3
2017-07-28 16:43:40 -07:00
Stephen Toub 11dea4f52d Disable default proxy credentials tests for managed handler (dotnet/corefx#22495)
One of these tests is now hanging on Unix after the updated connection
pooling changes went in.  Disabling for now.

Commit migrated from https://github.com/dotnet/corefx/commit/5c169a30fb200bd17fb49439c633d2a11773802d
2017-07-21 10:28:50 -04:00
Stephen Toub 01c662fdfd Address PR feedback
Commit migrated from https://github.com/dotnet/corefx/commit/4feb7fa2fcd2a2a4062a3ba8df4a2233d97af644
2017-07-20 17:15:39 -04:00
Stephen Toub 5f18995584 Improve connection pooling in ManagedHandler
Add support for purging stale connections from the pool and for a max number of connections per server.


Commit migrated from https://github.com/dotnet/corefx/commit/b52ad56a22e4bfabb55adc166396e1221b0e75f6
2017-07-19 23:28:54 -04:00
Stephen Toub a162c3892c Skip assert in Http SSL test on macOS (dotnet/corefx#22305)
Commit migrated from https://github.com/dotnet/corefx/commit/bb455945e6afe35d1b705c3590decdbcbfba5e5f
2017-07-18 11:42:35 -04:00
Stephen Toub fc393e88e9 Assert more details in Http SSL test failure (dotnet/corefx#22303)
Commit migrated from https://github.com/dotnet/corefx/commit/7d7a7efb58a49638e48c560631633730e10674dc
2017-07-15 22:54:00 -04:00
Lakshmi Priya Sekar f828d320fd Disable incompatible test on macos high sierra.
Commit migrated from https://github.com/dotnet/corefx/commit/c6afac0fb789e93431e3940e1ed08a2eabd3c344
2017-07-14 11:09:25 -07:00
Jeremy Barton 993c772595 Make ManagedHandler ConnectionPoolingTest clean itself up (dotnet/corefx#22267)
ManagedHandler_HttpClientHandler_ConnectionPooling_Test didn't assert
IDisposable (though did have a Dispose method), so it didn't clear the
environment variable that says to use the prototype managed handler in tests.
This means that any tests which should still be using the curl provider end up
using the managed provider until another managed test runs.

So now it's disposable, and a failure we were expecting, but not seeing, on
macOS 10.13 is asserting itself again.

Commit migrated from https://github.com/dotnet/corefx/commit/3dac2dbf20a56e6b525e078e977bfeed3ae8de8a
2017-07-14 12:49:38 -04:00
David Shulman 0e9da04ab9 Port TFS WinRT interop tests for HttpClient for UAP (dotnet/corefx#22239)
* Port TFS WinRT interop tests for HttpClient for UAP

Bring over the last of the WinRT interop tests for HttpClient. These
tests deal with interop between WinRT stream classes and .NET stream
classes.

Fixes dotnet/corefx#9044

* Address PR feedback


Commit migrated from https://github.com/dotnet/corefx/commit/7f4b8837ef77c3784cde0f57d17a5e656df86cb4
2017-07-14 09:01:11 -07:00
David Shulman 247c84a48c Reconcile behavior of MaxRequestContentBufferSize across .NET Core (dotnet/corefx#22201)
* Reconcile behavior of MaxRequestContentBufferSize across .NET Core

The HttpClientHandler property, MaxRequestContentBufferSize, has been
deprecated. This PR reconciles the behavior of the getter and setter of
the property.

Similar to other decisions in HttpClient PRs with these kinds of
behavior differences, we are not going to throw PNSE. We will document
the differences in the AppCompat docs.

Fixes dotnet/corefx#7879

* Address PR feedback


Commit migrated from https://github.com/dotnet/corefx/commit/e740973fed660da4426218bf2ec4be35a60ad095
2017-07-13 13:21:41 -07:00
David Shulman b85affb0a9 Adjust Http tests for UAP behavior differences (dotnet/corefx#22193)
Made changes to some UAP tests due to known platform differences.
Differences will be documented in the AppCompat docs.

Opened some new issues for bugs to investigate.

Fixes dotnet/corefx#22159
Fixes dotnet/corefx#22163

Commit migrated from https://github.com/dotnet/corefx/commit/1db009972e87bcdb719954bb6b00e19e67f4860b
2017-07-12 19:17:28 -07:00
David Shulman 9441d0365a Re-enable and fix Http tests for UAP (dotnet/corefx#22155)
* Re-enable anf fix Http tests for UAP

* Removed ActiveIssue from a bunch of Http tests.

* Converted some ActiveIssue to SkipOnTargetFramework due to
platform differences.

* Change some tests to use RemoteInvoke to get process isolation
since UAP will cache connections per-process.

* Removed a duplicate ChannelBinding test. There is already the
same test in HttpClientHandlerTest.ServerCertificates.cs
(PostAsync_Post_ChannelBinding_ConfiguredCorrectly). And that
test checks more things.

Contributes to dotnet/corefx#20010

* Address PR feedback


Commit migrated from https://github.com/dotnet/corefx/commit/a3cd07a7b608358710ac073cbe41f65866aa929a
2017-07-12 13:26:01 -07:00
David Shulman 113a821137 Fix HttpClientHandler UAP to use a filtered set of client certs (dotnet/corefx#22075)
* Fix HttpClientHandler UAP to use a filtered set of client certs

My earlier PR dotnet/corefx#22022 refactored the GetEligibleClientCertificates code
into a Common method. However, I neglected to actually use it in the UAP
HttpClientHandler!

Fixed the handler to properly filter down the set of client
certificates.

Added new tests to verify functionality. While doing this, I discovered
that the tests need to run in an isolated process due to the per-process
caching behavior of the UAP HTTP stack.

So, I used the RemoteInvoke method. I had to duplicate some of the new
tests using Fact instead of using Theory. This is because the
RemoteInvoke doesn't allow non-string parameters and I had to pass
in X509Certificate2 objects. So, I separated out each variant into its
own Fact test.

* Address PR feedback

* Fix code refactoring to properly filter client certificates.
* Fix test names in nameof() blocks.
* Disable a test from using the managed handler.

* Address PR feedback

* Remove unneeded using statements.
* Disable managed handler in some SslProtocols tests.


Commit migrated from https://github.com/dotnet/corefx/commit/9c4af2973699aea35ce5c60c00f7dd14398e7a14
2017-07-11 16:39:00 -07:00
David Shulman 823f81b56e Implement client certificates for HttpClient on UAP (dotnet/corefx#22022)
* Implement client certificates for HttpClient on UAP

Added code for HttpClientHandler.ClientCertificates on UAP.

Moved code duplicated in several places into a common helper class, CertificateHelper.
Then I discovered a bug introduced into GetEligibleCertificates (from PR dotnet/corefx#21908) that
doesn't properly filter by EKU or KeyUsage if there is only one cert (this was failing
the WinHttpHandler Unit tests). So, I removed that optimization.

Used the new Azure test endpoint for client certificates. I did not use the loopback
server because there is a problem using it with HttpClient in UAP. There is a crash
in the SslStream.AuthenticateAsServer that I was not able to diagnose yet. It will
require a lot of time debugging and I wanted to get this HttpClientHandler feature
done now. Tracking that investigation with dotnet/corefx#22021.

Fixes dotnet/corefx#21628
Contributes to dotnet/corefx#14542

* Address PR feedback

* Moved method to Windows-only Common file
* Fixed some line spacing

Other potential refactoring/optimizations will be looked into in dotnet/corefx#22045


Commit migrated from https://github.com/dotnet/corefx/commit/472b8d8ec212c2afb107dea305b4624c4989a79f
2017-07-10 16:52:07 -07:00
Stephen Toub ac9303e990 Disable GetAsync_UnsupportedSSLVersion_Throws test on Linux
Commit migrated from https://github.com/dotnet/corefx/commit/0b3134f7b9a2b2be73dcbfa0deca7a8da24d6621
2017-07-09 00:50:15 -04:00
David Shulman 465f5b4426 Modify some HttpClient tests to use RemoteInvoke on UAP (dotnet/corefx#22000)
* Modify some HttpClient tests to use RemoteInvoke on UAP

A few of the HttpClient tests were failing and needed to be isolated into their
own process. This is due to the UAP stack using per-process connection pooling.

Fixes dotnet/corefx#21945

* Address PR feedback


Commit migrated from https://github.com/dotnet/corefx/commit/69424bfe32417870a5b3047bad4958cc7fa5d9a8
2017-07-08 10:53:30 -07:00
Stephen Toub e4e0f8e85d Disable ManagedHandler negative test failing on older Windows 10 builds (dotnet/corefx#22002)
Commit migrated from https://github.com/dotnet/corefx/commit/99aa82499ef8fe11e6049a6ba2a636eb8780a520
2017-07-08 00:55:57 -04:00
Stephen Toub 783d69cc63 Use pending ReadAsync in ManagedHandler to detect closed connections (dotnet/corefx#21936)
Commit migrated from https://github.com/dotnet/corefx/commit/dc379629280346ddadd6ccbcc879833347271214
2017-07-07 07:32:40 -04:00
David Shulman 729e5773e4 Fix HttpClientHandler ServerCertificateCustomValidationCallback for UWP (dotnet/corefx#21905)
* Fix HttpClientHandler ServerCertificateCustomValidationCallback for UWP

This PR implements the ServerCertificateCustomValidationCallback for UWP. While implementing this, I discovered that the behavior of
the current .NET Core code is incorrect regarding how to propagate exceptions from the user provided callback. I opened up a new
issue dotnet/corefx#21904 and revised the test as well.

Fixes dotnet/corefx#21627

* Address more PR feedback


Commit migrated from https://github.com/dotnet/corefx/commit/e30fdc38e60f6fa2ed8e7e103d1f8c44655438cd
2017-07-06 17:22:50 -07:00
Stephen Toub da8094f0e5 Wrap CurlHandler cert validation callback exceptions in HttpRequestException (dotnet/corefx#21938)
* Wrap CurlHandler cert validation callback exceptions in HttpRequestException

* Address PR feedback


Commit migrated from https://github.com/dotnet/corefx/commit/9d74fcf4534894f375caebe20bfe62dd7af7fbd0
2017-07-06 16:37:20 -04:00
Stephen Toub 14de90821d Disable several ManagedHandler tests (dotnet/corefx#21907)
These were enabled as they weren't failing CI, but that's likely because they were being skipped rather than because they actually work.

Commit migrated from https://github.com/dotnet/corefx/commit/4a9d2b80677eb4e51892873b9dafe1fedfaeae22
2017-07-05 19:16:35 -04:00
Stephen Toub 9a99800209 Several test fixes to unblock failing tests
Commit migrated from https://github.com/dotnet/corefx/commit/a910d82cab99072c89746761d77b231c88ed5790
2017-07-05 14:02:33 -04:00
Stephen Toub 6a3070c094 Don't fail when there's no status description
Or when the status code doesn't have a known status description.


Commit migrated from https://github.com/dotnet/corefx/commit/a031a3b5d4199fe92efd9a7785fa67a79cafc53d
2017-07-05 12:43:12 -04:00
Stephen Toub 5f28d7f42c Enable most of ManagedHandler_HttpClientHandlerTest tests
Explicitly disabled a few that are failing.  We'll need to revisit those subsequently, but this at least gets most of the tests running.


Commit migrated from https://github.com/dotnet/corefx/commit/2179ea079abb5c15aeb0387c7e52ab25b8503713
2017-07-05 12:43:12 -04:00
Stephen Toub ba9c884896 Enable ManagedHandler_HttpClientMiniStress tests
One test needed to be fixed to deal with the fact that currently the ManagedHandler doesn't throttle connections and can end up getting denied connection errors from the server when exceeding the listen backlog size employed.


Commit migrated from https://github.com/dotnet/corefx/commit/47ffa8b49cf3d04be888f4d1e1dc287cdcbbe5e5
2017-07-05 12:43:12 -04:00
Stephen Toub f58d8f73a2 Add missing ManagedHandler derived test classes
I missed these when adding the derived types.


Commit migrated from https://github.com/dotnet/corefx/commit/c11593e8204d9ea8a664352dfef09b7d4edae4a2
2017-07-05 12:43:12 -04:00
Stephen Toub fd63714f4a Re-enable ManagedHandler_HttpClientHandler_ClientCertificates_Test and ManagedHandler_HttpClientHandler_ServerCertificates_Test
The tests that verify PNSEs getting thrown were failing incorrectly when the managed handler was used on platforms like CentOS where our CI system has an old libcurl installed.  For now, I've worked around it in a very manual fashion, but longer term we need a better way of using the same tests against multiple handlers substituted dynamically.


Commit migrated from https://github.com/dotnet/corefx/commit/fb2f2e8be64d6bf2c26030ef63d1e5cb004e8a64
2017-07-05 12:43:12 -04:00
Stephen Toub 0fac064c51 Enable ManagedHandler_HttpClientHandler_SslProtocols_Test tests
These are all passing now.


Commit migrated from https://github.com/dotnet/corefx/commit/17fc1976a479cd8977fb935bf2067f432d8d5db4
2017-07-05 12:43:12 -04:00
Stephen Toub 0b13c63547 Enable ManagedHandler_SchSendAuxRecordHttpTest tests
The managed client was more sensitive to timing issues resulting from the server not properly closing the connection.


Commit migrated from https://github.com/dotnet/corefx/commit/938e31584ba70a4272ac83b2fdf781d5d8cdc659
2017-07-05 12:43:12 -04:00
Hugh Bellamy 98b18432b7 Move AssertExtensions to Corefx.Private.TestUtilities (dotnet/corefx#21799)
* Move AssertExtensions to Corefx.Private.TestUtilities

* Update csprojs

* Fix Linq.Expressions uapaot build


Commit migrated from https://github.com/dotnet/corefx/commit/7e3b0db2892c56a431f8e99af9cd9381adec385a
2017-07-03 09:27:30 -07:00
Stephen Toub c6dcdd5c5a Re-disable a few ManagedHandler tests
The condition for these tests needs to be adjusted.  The tests in question are verifying that a PNSE is thrown on platforms that don't have an OpenSSL backend, but that's irrelevant when using the managed handler, on which these tests actually successfully make connections rather than throwing.

Committing directly to unblock CI.

Commit migrated from https://github.com/dotnet/corefx/commit/4f9322825a9da4f47677b1413f0feabed3fd746b
2017-07-02 11:35:14 -04:00
Stephen Toub e0a5ae3073 Disable one test and clean up some TODOs
Commit migrated from https://github.com/dotnet/corefx/commit/9e97d0d8eb8e3d643bbf485a4ea758535c287dbd
2017-06-30 17:30:14 -04:00
Stephen Toub 849ab9a89b Separate ManagedHandlerTestHelpers into its own file
Commit migrated from https://github.com/dotnet/corefx/commit/083a1dc85c21ecb980e0af58f78af7af87254edd
2017-06-30 17:15:18 -04:00
Stephen Toub 8909da570e Fix several PostScenarioTest tests
Tests expect that IOExceptions and InvalidOperationExceptions from SendAsync are wrapped in HttpRequestExceptions.


Commit migrated from https://github.com/dotnet/corefx/commit/4ed7139a9755db8a1a1c50a1365d8ab15c66fd9a
2017-06-30 17:11:44 -04:00
Stephen Toub ca58a45b18 Fix SafeFreeContextBufferChannelBinding.ToString()
One of the Windows-only tests is expecting SslStream's ChannelBinding's ToString() to output the data from the binding in a specific format, matching what WinHttp's outputs.  This makes that happen.  And enables more tests.


Commit migrated from https://github.com/dotnet/corefx/commit/0cd7eeabb6b91c44827592bd45f8312dcb961388
2017-06-30 17:11:44 -04:00
Stephen Toub 96d042f9ab Fix handling of 0-byte reads
And re-enable some tests that were tripping over them.


Commit migrated from https://github.com/dotnet/corefx/commit/32b5f3e3fb8ae4611ac1b2edce11d54849ba19f2
2017-06-30 17:11:44 -04:00
Stephen Toub 55108cffa3 Merge pull request dotnet/corefx#21750 from stephentoub/fix_linux_tests
Enable a bunch of ManagedHandler tests

Commit migrated from https://github.com/dotnet/corefx/commit/3435cab26d7362169e8e19c2ec711d8126dc42db
2017-06-30 17:09:26 -04:00
Stephen Toub 112aba715d Enable a bunch of tests for ManagedHandler
Commit migrated from https://github.com/dotnet/corefx/commit/eeb86610d8bcb9b38733d57279baf93e9ae68274
2017-06-29 22:01:11 -04:00
Cristian Pop 23a2417388 Tracking ETW UAP test failures against a single issue. Global mutex is not supported in UAP. (dotnet/corefx#21732)
* Removing Global mutex bug ID. Tracking ETW UAP test failures against a single issue.
* Disabling EKU tests for UAP.

Commit migrated from https://github.com/dotnet/corefx/commit/12632fd50d02c1b1934cac13edc8225304ac91a5
2017-06-29 16:22:14 -07:00
David Shulman 7e59e3b2a7 Clarify default credentials usage for HttpClientHandler on UAP
This PR clarifies how credential handling and specifically default
logged-on credentials actually works on the UAP platform.

First, "default credentials" are the current credentials of the
logged-on user, typically on an enterprise network joined to an
Active Directory domain. When these credentials are sent to a
proxy or server, only Negotiate, Kerberos, or NTLM schemes are
used. Those credentials can never be sent via other schemes
like basic or digest.

.NET Framework traditionally has two ways for developers to specify
using default logged-on credentials to send to the server. Either
set the .UseDefaultCredentials property to true or specify
CredentialCache.DefaultCredentials to the .Credentials property.

For proxy credentials, the developer could pass DefaultCredentials
via the custom IProxy object or via the .DefaultProxyCredentials
property.

.NET Framework would send default credentials anywhere (intranet
or internet) if specified by the developer.

The UAP platform implementation of System.Net.Http uses a different
set of rules for sending default credentials. It is based on whether
the app has Enterprise Authentication capability as well as if the
endpoint is specified in an intranet zone. This design is part of
the base native WinInet and WinHTTP stacks. It was a design choice
to provide optimum security as well as convenience for developers
writing apps for enterprise scenarios.

This PR does a few things. First, it keeps the .NET ICredentials
properties stored separately so that they correctly round-trip
on get and set. .NET NetworkCredential has 3 parameters (domain,
user, password). But WinRT PasswordCredential only has 2 parameters
(user, password). We now convert to the WinRT objects only when
we need to use them.

Second, this PR clarifies that the .UseDefaultCredentials property
is basically a no-op because the API models of default credentials
handling is different on the UAP platform as described above.

These platform differences will be documented here:
https://github.com/dotnet/corefx/wiki/ApiCompat

Fixes dotnet/corefx#19642
Fixes dotnet/corefx#21510


Commit migrated from https://github.com/dotnet/corefx/commit/2c33453f3e4064c75d404c6f3590ddf00a377d10
2017-06-28 11:50:27 -07:00
David Shulman 65782675d6 Fix some TLS related HttpClientHandler properties for UAP (dotnet/corefx#21630)
Due to platform differences on UAP and the current use of WinRT APIs to
implement that HTTP stack, a few properties won't have the same defaults
or behavior.

CheckCertificateRevocationList default value is true for UAP and can't
be changed. However, on UAP, revocation checking that results in an
indeterminate status (i.e. revocation server offline) is treated the
same as a valid result. This is the behavior of the underlying WinRT
APIs.

SslProtocols default value is SslProtocols.None which is the same as the
rest of .NET Core. 'None' means to use the system default. However, changes
to this property value will be ignored.

Similar to the decision made in PR dotnet/corefx#21403, we don't throw PNSE for these
differences. Instead we just no-op on the property setter.

The behavior differences will be documented in:
https://github.com/dotnet/corefx/wiki/ApiCompat

Contributes to dotnet/corefx#18116.

Commit migrated from https://github.com/dotnet/corefx/commit/711f785f072c8131b9d49792eeab02d2d55be662
2017-06-27 14:34:03 -04:00
David Shulman 15fcaa332b Address PR feedback
Commit migrated from https://github.com/dotnet/corefx/commit/b690cd329dba0da32824b29eeb3945d6d11f6085
2017-06-24 21:20:40 -07:00
David Shulman 07b1b1c311 Fix some HttpClientHandler properties for UAP
Due to platform differences on UAP and the current use of WinRT APIs to
implement that HTTP stack, a few properties won't have the same defaults
or behavior.

Similar to the decision made in PR dotnet/corefx#21403, don't throw PNSE. Instead
just no-op.

Fixes dotnet/corefx#18036 dotnet/corefx#17812


Commit migrated from https://github.com/dotnet/corefx/commit/0de066e0bc3b67b6bc6fd1db26abea2cda1ce4d9
2017-06-24 14:14:45 -07:00
Hugh Bellamy 7cbcd5ed85 Convert most Assert.Throws<ArgumentException> without param name to AssertExtensions (dotnet/corefx#21455)
* Registry

* Collections

* ComponentModel

* Configuration

* Data

* Globalization

* Drawing

* Diagnostics

* IO

* Linq

* Add System.Net param names in tests

* Move ArgumentExceptions in System.Private.Xml to AssertExtensions

* Add System.Reflection.* ArgumentException param names

* Add param names for System.Runtime* ArgumentExceptions

* Add ArgumentException param names to System.Security.*

* Add ArgumentException param names to System.Text.*

* Add param names to ArgumentExceptions in misc projects

* Add System.Threading.* ArgumentException param names

* Fix missing files

* Fixes for unix and netfx

* Fix more failures and revert a IdnaConformance tests to avoid merge conflicts with dotnet/corefx#21463


Commit migrated from https://github.com/dotnet/corefx/commit/59915687bb261efeae70565d0ca8990ac45ceb9c
2017-06-23 12:33:47 -07:00
David Shulman 21b6b7e235 Fix HttpClientHandler PreAuthenticate property for UAP (dotnet/corefx#21403)
The HttpClientHandler for UAP does not properly implement the PreAuthenticate
property. This is because on UAP, HttpClientHandler is built on the WinRT
APIs which in turn are built on WinInet. And WinInet always uses authentication
caching internally and this results in the net effect of PreAuthenticate always
being "true".

The default for .NET Framework and .NET Core (non-UAP) is "false".

When this property was first added to .NET Core 1.1, the UAP version defaulted
to true and the setter would throw PNSE.

As part of .NET Core 2.0, API surface for networking APIs was expanded. This
resulted in HttpWebRequest exposing and implementing a "PreAuthenticate" property,
which is what it has historically done in .NET Framework. On .NET Core, HttpWebRequest
is built on top of HttpClient. And so, HttpWebRequest was enhanced in .NET Core 2.0
to set the default of PreAuthenticate to false. But this later caused the PNSE
exception to surface and this exception was caught in UWP app-compat testing.
Essentially, we had now created the default HttpWebRequest to always throw an
exception.

So, in PR dotnet/corefx#18105, the PNSE in HttpClientHandler.PreAuthenticate was commented out
and thus the setter became a no-op.

This PR basically acknowledges this situation and removes the TODO from this change.
Since there is no good way to implement the actual HttpClientHandler.PreAuthenticate
property, I left the getter default to return "true" which is closer to reality of
what happens on UAP (even though this default value is different from .NET Framework
or the rest of .NET Core). And, in terms of the setter for the property, I opted to
leave it as a no-op. This seems like the best compromise outcome for now and will
generate less distraction for developers rather than throwing an exception all the
time.

The rest of this PR moves the ActiveIssue's from the class level to the method level
as part of eventually solving all of them. In addition, I added a new test case to
validate the HttpClientHandler constructor defaults that are different on the UAP
platform.

Fixes dotnet/corefx#18104

Commit migrated from https://github.com/dotnet/corefx/commit/c3b2f15d90972a5607415582681584965f16c01d
2017-06-23 05:26:07 -04:00
Stephen Toub c8becd18b6 Merge pull request dotnet/corefx#21232 from stephentoub/managedhttpclient
Add managed HttpClientHandler prototype as opt-in

Commit migrated from https://github.com/dotnet/corefx/commit/93ee4ba40c82d5aca978447cb3e14c4ef7e7fd53
2017-06-22 20:02:18 -04:00
Stephen Toub e48e6320e3 Disable ManagedHandler tests temporarily
Commit migrated from https://github.com/dotnet/corefx/commit/7715ca680965f3d0de70875c6a788e36e404e6dd
2017-06-22 18:35:34 -04:00
David Shulman 59cc606beb Fix DefaultProxyCredentials edge case on NETFX
After my PR dotnet/corefx#21325, I discovered an edge case where we need to check for
a non-null Proxy property in the underlying WebRequest.

On .NET Framework, System.Net.Http is built on WebRequest
(HttpWebRequest) and is subject to side-affects from it. The static
property WebRequest.DefaultWebProxy affects the initial value of
WebRequest.Proxy. So, it's possible that a developer may have set
WebRequest.DefaultWebProxy to null prior to using System.Net.Http in the
app.

The net affect of this is that that won't be any proxy used as the
system default proxy and thus the
HttpClientHandler.DefaultProxyCredentials is ignored.

On .NET Core, there is no relationship between System.Net.Http and
System.Net.WebRequest.  So, in all cases on .NET Core, where a developer
has specified HttpClientHander.UseProxy=true and HttpClientHandler.Proxy
= null (default values), the handler will always try to use the system
default proxy (if configured).


Commit migrated from https://github.com/dotnet/corefx/commit/eac755df47f70e5ef3853c0b71ed4ab12455bb96
2017-06-22 09:52:34 -07:00
Stephen Toub 1de0cf31b0 Integrate ManagedHandler into Windows and Unix builds
- Add a ManagedHandler field to both the Windows and Unix HttpClientHandler builds, and change the members to switch based on which is being used.  The default is still to use WinHttpHandler and CurlHandler respectively, but setting an environment variable prior to constructing an HttpClientHandler will switch it to use ManagedHandler.
- Add test classes that will run the tests again but with the managed handler.  Some of the test classes are commented out due to current failures.
- Fixed a few tests.


Commit migrated from https://github.com/dotnet/corefx/commit/b238d0d760a2588513c443f3a4c991222fd037bb
2017-06-22 09:26:46 -04:00
David Shulman 093520dcc8 Fix HttpClientHandler.DefaultProxyCredential on NETFX
This bug was discovered in internal testing when this code was being
ported to .NET Framework vNext.  Due to all these tests being previously
disabled on NETFX, the bug was missed.

The HttpClientHandler.DefaultProxyCredentials property is only used when
an explicit proxy is not specified (HttpClientHandler.Proxy==null) but a
proxy is still desired (HttpClientHandler.UseProxy==true). In this case,
the semantics implied are to use the system default proxy settings to
find a proxy.  In that case, the credentials specified by
DefaultProxyCredentials should be passed to the webrequest.Proxy object
which, by default, points to the system proxy.


Commit migrated from https://github.com/dotnet/corefx/commit/e5306b55c0267c0369e5da9bef0467d2ea4e9b51
2017-06-21 12:33:23 -07:00