Commit Graph
1199 Commits
Author SHA1 Message Date
Stephen Toub 9ed67baf58 Replace some hardcoded strings in the implementation
Commit migrated from https://github.com/dotnet/corefx/commit/054c6ab6895ccce97e0e9d980503fa12d0d21594
2017-06-26 23:01:42 -04:00
Stephen Toub 30740c9062 Rename CopyFromBufferAsync to end in Async
Commit migrated from https://github.com/dotnet/corefx/commit/edc02ea7140e0b5571563f6af98c222fb32a9da7
2017-06-26 23:01:42 -04:00
Stephen Toub 44300123ff FlushAsync need not be an async method
Once we pass the _writeOffset to WriteAsync, we've copied it, so we can immediately zero out the field and just return the WriteAsync task, rather than wrapping it in another async method.


Commit migrated from https://github.com/dotnet/corefx/commit/10b23970906ac7eacb4e05898bb9fc42b291fa94
2017-06-26 23:01:42 -04:00
Stephen Toub df60499619 Remove some overhead from FillAsync
FillAsync does a single async read, and the only thing it does after that is updating the stored length.  We can use ContinueWith rather than async/await in this case to avoid a small amount of overhead.


Commit migrated from https://github.com/dotnet/corefx/commit/47f14c20143f4252afc3e60550b79be1e48e1386
2017-06-26 23:01:42 -04:00
Stephen Toub e51b594c04 Remove intermediate async method when no proxy Uri
Commit migrated from https://github.com/dotnet/corefx/commit/16ffd461934b9b494bab050f55cc51943c985d4c
2017-06-26 23:01:42 -04:00
Stephen Toub bd2ffdb8cf Remove async yielding method from HttpConnectionHandler
When we get a connection from the pool, we don't need the intermediary async method.


Commit migrated from https://github.com/dotnet/corefx/commit/63d0493d0276bb32db2634f52329b19f68136922
2017-06-26 23:01:42 -04:00
Stephen Toub d803ddb29a Use cached header names and reason phrases
Commit migrated from https://github.com/dotnet/corefx/commit/b6710956a12c702f72477d6cda4dd5db797977a2
2017-06-26 23:01:42 -04:00
Stephen Toub f03d1ab921 Fixed !!_disposed typos
Commit migrated from https://github.com/dotnet/corefx/commit/8e32964318e081d727771d6302d1407767875e71
2017-06-26 23:01:42 -04:00
Stephen Toub f2ca7ef4ff Add WriteAsciiStringAsync helper
We can avoid per-char ASCII checks for cases where the string is already known to be ASCII only.


Commit migrated from https://github.com/dotnet/corefx/commit/aecd8c20ddf3dbd47d4622120498ae50a5917468
2017-06-26 23:01:42 -04:00
Stephen Toub 2264071d51 Avoid setting Host header
Doing so incurs a variety of allocations.  Better to just output the header if we need to.


Commit migrated from https://github.com/dotnet/corefx/commit/63e5cd798774343da38256c9f0069a20f9c1a15f
2017-06-26 23:01:42 -04:00
David Shulman 554f8f2fbd Remove outdated TODO in HttpClientHandler for UAP
The current behavior for .NET Core (Windows, *Nix, and UAP) is to use a
default HTTP version if none or an illegal version is specified.

On .NET Framework, an exception is thrown in these cases, "Only HTTP/1.0
and HTTP/1.1 version requests are currently supported." This error
message wouldn't make sense now anyways since HTTP/2 is supported in
.NET Core. So, it is better to use a default version than to throw an
exception.

This difference between .NET Core and .NET Framework will be document
here:
https://github.com/dotnet/corefx/wiki/ApiCompat

Fixes dotnet/corefx#7878


Commit migrated from https://github.com/dotnet/corefx/commit/693f6dacd3b60af2b2ace76872e5644dcc03b68c
2017-06-26 15:36:58 -07:00
David Shulman 33911341ca HttpClienthandler code cleanup for UAP (dotnet/corefx#21528)
This file had never been formatted according to CoreFx style guidelines
when the code was first ported into GitHub.

Now that we are doing NETStandard2.0 work, I wanted to clean up this
file to avoid distractions as I add features.

Commit migrated from https://github.com/dotnet/corefx/commit/e92a6a087acb32f37fa7628cc92c76903733f73d
2017-06-25 17:52:40 -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
Stephen Toub d27e97ef82 Merge pull request dotnet/corefx#21458 from stephentoub/cleanup_writes
Some more miscellaneous ManagedHandler cleanup

Commit migrated from https://github.com/dotnet/corefx/commit/7d211a8d432ed70243b1fa8d627a64483d99e226
2017-06-23 21:31:44 -04: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
Stephen Toub 3b9ae05401 Clean up some unnecessary ValueTask<bool>s
These can just use Task and Task.CompletedTask.  Also fix some throws that should return a faulted task.


Commit migrated from https://github.com/dotnet/corefx/commit/81ca4a02a0556509bfa29b470a5d79fee0618849
2017-06-23 10:27:56 -04:00
Stephen Toub 7db5721a22 Clean up individual WriteCharAsync calls
- No need to validate that chars are ASCII when we know they are
- We can output strings just by copying bytes rather than processing individual chars


Commit migrated from https://github.com/dotnet/corefx/commit/3dc7379064780a0e95af87b0a425ba0258f2892e
2017-06-23 10:27:56 -04: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 400480d0cb Optimize several range checks
Commit migrated from https://github.com/dotnet/corefx/commit/566a1166a167dce5b652ead0191ff87b78a36575
2017-06-22 23:14:05 -04:00
Stephen Toub d2912c5a0e Some more random cleanup
- Apply IDE simplifications for things like null checks during assignments
- Fix GetOrAdd calls to only allocate if necessary
- Use throw expressions in a few places
- Add some readonlys to fields
- Change some .Waits to .GetAwaiter().GetResult()s
- Remove some unnecessary abstract overrides
- Remove some unnecessary usings


Commit migrated from https://github.com/dotnet/corefx/commit/dc01adf473ae5031be436808bf4b310c364c4268
2017-06-22 23:08:51 -04:00
Stephen Toub 664af10a1e Seal a few handler classes
Commit migrated from https://github.com/dotnet/corefx/commit/6bfa459cd0e5ad2d4e34269d5d1e582819f372b9
2017-06-22 22:47:31 -04:00
Stephen Toub 023a9f9f2c Use ValueTask in a few more async helpers
Commit migrated from https://github.com/dotnet/corefx/commit/fe6ec3c381011f8227bf36fb93b54ac54536bad7
2017-06-22 22:46:04 -04:00
Stephen Toub dbde958bef Add ConfigureAwait(false) to all ManagedHandler awaits
Commit migrated from https://github.com/dotnet/corefx/commit/5091a2960d83bcd9a96420f65ff38053ce97f931
2017-06-22 22:39:31 -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
Stephen Toub 7e7e9e5056 Minimally address PR feedback
The primary purpose of the PR is to get the code into the repo (not enabled by default), so most PR feedback is being left for subsequent PRs.  However, this commit addresses the feedback deemed imperative to fix prior to initial merge.


Commit migrated from https://github.com/dotnet/corefx/commit/5c86b5e5e1a6896e0be396a6422e8f3ebed78648
2017-06-22 16:33:52 -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 2b0796d870 Add README.md
Commit migrated from https://github.com/dotnet/corefx/commit/03334db81a7d6af17bd40ff27915780e10495c65
2017-06-22 09:26:46 -04: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
Geoff Kizer 1e97b3d02d Initial prototype of managed HttpClientHandler
Commit migrated from https://github.com/dotnet/corefx/commit/0893c2a886f4cef21697a570a26819b0c7640f9c
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
Stephen Toub d0331b469f Fix MaxResponseContentBufferSize handling (dotnet/corefx#21145)
It's not causing failures in all cases it should, as it's comparing against a buffer size that may have grown to be larger than the desired max.

Commit migrated from https://github.com/dotnet/corefx/commit/517b9dd71b83659b4ce5fbd7f4fe1b749a7579b1
2017-06-16 21:54:25 -04:00
David Shulman d81ad4080f Disable bad certificates tests on Windows (dotnet/corefx#21090)
Due to issues with dotnet/corefx#7812 and certificates using DHE ciphers, we're
disabling these tests on Windows for now.

I am in the process of moving these tests from the *.badssl.com servers
to servers that we control in Azure that won't use DHE cipher suites.

Related to dotnet/corefx#7812

Commit migrated from https://github.com/dotnet/corefx/commit/187bf4cd817637a3505d69f1c08ec80938b02d82
2017-06-15 13:38:09 -04:00
Tarek Mahmoud Sayed 8754550d62 Enable UAP Remote Execution for all tests (dotnet/corefx#21014)
This change to enable remote execution of all corefx tests in UAP. Because the remote execution code for UAP is using WinRT APIs and to avoid forcing adding UAP configuration to all test projects, we factor the remote execution code into its own test library (called TestHelper) which is cross compiled.

Commit migrated from https://github.com/dotnet/corefx/commit/eb2f543b189e8f7f9ae4c31e832ac9d3c22bb41a
2017-06-14 13:26:57 -07:00
Kristian Hellang 48be6a37c8 Remove default libcurl Content-Type header for empty POST requests (dotnet/corefx#20738)
* Added test to make sure Content-Type isn't sent for empty POST requests

* Remove default libcurl Content-Type header for empty POST requests


Commit migrated from https://github.com/dotnet/corefx/commit/fdb309f1421d4006c609097fd4b48443d3b1ad18
2017-06-06 17:46:41 -04:00
David Shulman 7991f4d912 Fix WinHttpResponseStream when reading 0 bytes
Fixes dotnet/corefx#20676


Commit migrated from https://github.com/dotnet/corefx/commit/f6e51aec3270102234386454063d66251f3b901b
2017-06-05 10:43:39 -07:00
Stephen Toub a18f9870b9 Fix HttpClient on Unix handling of 0-len content with chunked upload
Commit migrated from https://github.com/dotnet/corefx/commit/c4fe0654ddc54d1ddb505d020f38392b3a552032
2017-05-31 00:04:37 -04:00
Jose Perez Rodriguez 3391823eaf Merge pull request dotnet/corefx#20369 from joperezr/SystemNetHttp
Fixing System.Net.Http.Functional tests on uapaot

Commit migrated from https://github.com/dotnet/corefx/commit/0a382e75df38a5c1d2cac2f4e34170961c198dab
2017-05-26 16:31:11 -05:00
Jose Perez Rodriguez 7ce5531fcc Fixing System.Net.Http.Functional tests on uapaot
Commit migrated from https://github.com/dotnet/corefx/commit/692343761c582dba996f83abfffe150bf854a614
2017-05-26 11:24:34 -07:00
Eric St. John af1d155bf6 Remove help VS comments
Many CSProjs included the comment
`<!-- Help VS understand available configurations -->`

These aren't handled well by the tooling that rewrites projects and weren't providing much value.

Remove them.


Commit migrated from https://github.com/dotnet/corefx/commit/5ba948d13e3177c2c7075b6b00791e574bfa0860
2017-05-25 11:10:27 -07:00
Stephen Toub 1d07613e4c Fix off-by-one error in NetEventSource.WriteEvent
Commit migrated from https://github.com/dotnet/corefx/commit/084a236715292df1bc5448f60cce4c3ba9ab5df2
2017-05-24 07:31:21 -04:00
Stephen Toub d437802c49 Merge pull request dotnet/corefx#20095 from stephentoub/http_tracing
Add more tracing to HttpClient on Unix

Commit migrated from https://github.com/dotnet/corefx/commit/4709a5cda50ec3d141b5b460bc05c8b576332659
2017-05-23 12:02:01 -04:00
Stephen Toub e687c3c3ae Merge pull request dotnet/corefx#20145 from safern/DisableNetTests
Disable System.Net.* tests for issue dotnet/corefx#19967

Commit migrated from https://github.com/dotnet/corefx/commit/d59a6a31c7a9106821443002b04ce56b82f0b35f
2017-05-22 23:11:28 -04:00
Santiago Fernandez 96d1270381 Disable System.Net.* tests for issue dotnet/corefx#19967
Commit migrated from https://github.com/dotnet/corefx/commit/ec8df2b33e5a155325228fda75792c5319126f28
2017-05-22 16:32:50 -07:00
Santiago Fernandez Madero c65dd7a4bd Test attributes cleanup for Uap now that Uap flag includes UapAot (dotnet/corefx#20108)
* Update xunit extensions to unify TargetFrameworkMonikers.Uap to include UapAot

Commit migrated from https://github.com/dotnet/corefx/commit/652d12bf31606eeef8fe8b9a7bf1cc7af06f6352
2017-05-22 15:10:24 -07:00
David Shulman 86808fb7eb Merge pull request dotnet/corefx#20011 from schen381/7812_code
Investigate WinHttpException: buffer too small

Commit migrated from https://github.com/dotnet/corefx/commit/c107332781a8cb326d674a825f8817e18d464df6
2017-05-22 13:06:56 -07:00
Stephen Toub e1a1be9fc0 Add more tracing to HttpClient on Unix
Some recent investigations based on tracing data revealed some gaps in usefulness.  This adds some more tracing to try to fill those gaps.


Commit migrated from https://github.com/dotnet/corefx/commit/e1daed6dac665c660c92255bbc2a2a7eee31e066
2017-05-22 10:07:37 -04:00
David Shulman d899bda510 Disable System.Net.Http tests on UAP/UAPAOT (dotnet/corefx#20017)
Disable a bunch of System.Net.Http tests on UAP/UAPAOT platform.

Both inner and outer loop tests now run clean for System.Net.Http

Commit migrated from https://github.com/dotnet/corefx/commit/38cd7f91dbbc5ac4001bf15762a8e244f5ec3a70
2017-05-19 14:28:54 -07:00
Caesar Chen cb13973e33 Add instrumentation for now to catch unexpected errors and fail fast and produce a crash dump
Commit migrated from https://github.com/dotnet/corefx/commit/eb28853edaa8f3efcce225e3cbec5e1500be57b4
2017-05-19 11:46:13 -07:00