Commit Graph
203 Commits
Author SHA1 Message Date
Eric Erhardt 2c3e768b15 Shims should use intptr_t for file descriptors.
Changing all file descriptors used in System.Native to use intptr_t instead of int32_t.  This way we can marshal SafeHandles without having to add DangerousAddRef/Release code.

Fix dotnet/corefx#2904.


Commit migrated from https://github.com/dotnet/corefx/commit/8a5cbc165a696b39b8d9bb48554c09473d4ca6bc
2015-12-02 22:30:06 -06:00
Wes Haggard 11d572df6c Merge pull request dotnet/corefx#4780 from dsgouda/libporting
Created .builds files for building libraries 

Commit migrated from https://github.com/dotnet/corefx/commit/8564df2594e2bcca684103584fd42fc9b44bf46e
2015-12-02 16:01:47 -08:00
Deepak Shankargouda f5284f6fcc Created initial set of .builds files
Commit migrated from https://github.com/dotnet/corefx/commit/a20fd22b1e44d13e437c235a957a47a2af52838d
2015-12-02 14:38:03 -08:00
stephentoub 6d3b475032 Enable pipelining for HTTP/2 requests
Commit migrated from https://github.com/dotnet/corefx/commit/131c1c6fbfbac7c530247bb96176a45c9bc224ad
2015-12-02 12:29:50 -05:00
stephentoub cf77b65e40 Address PR feedback and fix a few tests
Commit migrated from https://github.com/dotnet/corefx/commit/3e205589a9e17a5b8ff9a4971e227d5f46c7e4c0
2015-12-01 15:38:35 -05:00
stephentoub 00b66c3db3 Add HTTP/2 support to HttpClient on Unix
The latest versions of libcurl have HTTP/2 support; this commit enables that to be used from HttpClient via setting the request Version.  Setting the Version will now pass along that version preference to libcurl; if it's set to 2.0, libcurl will use HTTP/2 if supported, otherwise it'll fall back to its default (1.1).  As part of this I also fixed CurlHandler to pass along v1.0 and v1.1 so libcurl can respect the developer's explicit wishes.

(Note that the HTTP/2 light-up is only available if libcurl supports it.  libcurl relies on nghttp2, which needs to be installed, and a version of libcurl needs to be used that's built against it.  To test, I built these locally from source.)


Commit migrated from https://github.com/dotnet/corefx/commit/3440aa3cdbd6f82de3746762a08eb796b8b3d90a
2015-12-01 14:38:01 -05:00
Hemanth Kapila 9bb74790f3 Fix CurlHandler to allow empty headers in redirect
libcurl does not pass empty headers in case of a redirect uri. This
results in discrepency between CurlHandler and UnixHandler. To work
around this, we set the request headers again in response to a redirect.


Commit migrated from https://github.com/dotnet/corefx/commit/411f1013b2154715ded08ffa27e50f4160f80d08
2015-11-26 09:39:39 +05:30
Hemanth Kapila e1bc6b18f6 Enable ChannelBinding Test for CurlHandler
Enabling Channel Binding test for curlhandler.


Commit migrated from https://github.com/dotnet/corefx/commit/4bcdb1400b85d2a3d9a0b1bc04e5c08c10f51851
2015-11-23 16:13:38 +05:30
stephentoub dd75517d24 Ensure CurlHandler sends headers with empty values
By default libcurl drops headers with empty values, as it uses an empty value as a sentinel to mean "remove a previously added header with this key name."  If you actually want a header with an event value, it needs to have a semicolon appended to the key name.


Commit migrated from https://github.com/dotnet/corefx/commit/93a9704371ab0b45794f2faa39cefb736c9a71a5
2015-11-19 23:04:29 -05:00
Hemanth Kapila 56a3abf10b Use libcurl+openssl to support TLS client certs
Make curlHandler support Client Certificates when the linked libcurl's
ssl backend is compatible with openssl. CurlHandler is also updated to
support ChannelBindingToken


Commit migrated from https://github.com/dotnet/corefx/commit/d3be6bbe9aee8f748f2688fb7bb00c577ac4b11e
2015-11-19 22:31:20 +05:30
Cristian Pop 40dcf58810 Removing SSLv2 and SSLv3 support from System.Net.Security.
APIs will throw NotSupportedException if SSLv2 or v3 is used. This
behavior is different from .NET Desktop.
Tests have been changed to pin this new behavior.
Increased passing-test timeouts to 15s.

Fix dotnet/corefx#3114 (partial), dotnet/corefx#4467


Commit migrated from https://github.com/dotnet/corefx/commit/1f4deea8946d2e54dfd3c88e64c85bc3c3d9805c
2015-11-16 11:26:00 -08:00
stephentoub a7eea95be5 Replace faulty assert in CurlHandler with proper handling
CurlHandler's support for pausing the connection needs to be resilient against spurious unpausing.  This commit just removes a faulty assert for a condition that is possible and replaces it with proper handling (repausing).


Commit migrated from https://github.com/dotnet/corefx/commit/ce27027eb8924d32b5d75d4c46d36660e98570ee
2015-11-11 12:30:23 -05:00
Eric St. John 65210efd31 Update project.lock.json to latest and lock
Commit migrated from https://github.com/dotnet/corefx/commit/6aeea5eabf2aff3baf15f501cabd156dfc5b3f8f
2015-11-09 22:38:10 -08:00
Eric St. John cddddd29f5 Remove unused dependencies
Commit migrated from https://github.com/dotnet/corefx/commit/78fd45ec74afc507a40df519b4df650ac9bd4c42
2015-11-09 22:37:37 -08:00
David Shulman df05d9fc0f Rename HttpTestServers2.cs to HttpTestServers.cs
Commit migrated from https://github.com/dotnet/corefx/commit/36acb05abd55f62aad0c18bc6ede2cef1c58628e
2015-11-09 11:20:41 -08:00
David Shulman b14cd70e12 Cleanup System.Net.Http tests
* Move more tests to the new test server
* Cleanup 'var' coding patterns
* Remove duplicate tests (*Content clas related) that are already covered with the *Content class tests
* Utiilize the newer test server VerifyUpload endpoint which does 'Content-MD5' verification of transmitted payload to the server
as well as payload from the server
* Add GZip related tests in addition to Deflate compression schemes


Commit migrated from https://github.com/dotnet/corefx/commit/773c8ae1db5aa7e5d695a74fb63968382f8529da
2015-11-09 07:05:24 -08:00
Eric Erhardt e703bc01ff Respond to PR feedback.
Instead of creating 5 safe handles to native code, only allocate a single native handle in EasyRequest. The single native object will hold all the function and user data pointers necessary to invoke the managed callbacks.


Commit migrated from https://github.com/dotnet/corefx/commit/6fa52c6daed5675662140ec23c2e76cd8f64ce5d
2015-11-06 10:25:14 -06:00
Eric Erhardt 30629511ce Add shims for Seek and ReadWrite callbacks in libcurl.
Since libcurl defines callbacks with varying signatures from platform to platform, we need to define a signature for the callbacks that doesn't change. Then we register our own native callbacks, which then converts the parameters from the varying signature to the unchanging signature and invokes the managed callback.


Commit migrated from https://github.com/dotnet/corefx/commit/c874d10c29ae61f7e16f8cea327c1ae14f7568ea
2015-11-06 10:25:09 -06:00
Eric Erhardt 23326060ee Merge pull request dotnet/corefx#4267 from eerhardt/ShimMulti2
Add shims for libcurl multi_* functions.

Commit migrated from https://github.com/dotnet/corefx/commit/16676760efc66253f4148390825b5aca0e1dd557
2015-11-02 11:46:53 -06:00
Eric Erhardt 26a1c9bf83 Respond to PR feedback.
Commit migrated from https://github.com/dotnet/corefx/commit/18248105021cac41ac67f831e36a9b092a2e6869
2015-11-02 10:54:52 -06:00
Eric Erhardt ca320526a4 Remove "libcurl" from Interop.Libraries.
Commit migrated from https://github.com/dotnet/corefx/commit/d7dca1088ecc8b487e4bb02574b2f6b36510d63a
2015-10-30 16:39:38 -05:00
Eric Erhardt 3d4a1d83a4 Add a shim for curl_multi_wait.
Commit migrated from https://github.com/dotnet/corefx/commit/f09762189ce3813017f375a27e29559aba200117
2015-10-30 16:25:25 -05:00
David Shulman e222a9ff11 Merge pull request dotnet/corefx#4255 from davidsh/streaming_fix
WinHttpHandler ResponseStream reads should return back with partial data

Commit migrated from https://github.com/dotnet/corefx/commit/383db8b8a8b5a83e540d7fcb952e0e9b4f2da6c4
2015-10-30 14:08:16 -07:00
Eric Erhardt 938710f93d First round of libcurl Multi shimming.
Commit migrated from https://github.com/dotnet/corefx/commit/c85bae2550b24149b5419b6065ec1ab614a3debb
2015-10-30 13:39:46 -05:00
David Shulman 10763035db WinHttpHandler WinHttpResponseStream reads should return back with partial data
.NET Stream.Read() semantics leave it to the implementation to decide how much data to return given a buffer of size N:

https://msdn.microsoft.com/en-us/library/system.io.stream.read(v=vs.110).aspx
"An implementation is free to return fewer bytes than requested even if the end of the stream has not been reached."

The behavior of System.Net HTTP APIs (i.e. .NET Framework) are such that stream reads are able to return as soon as data is available. They don't wait until the provided buffer is full. The current WinHttpHandler was not behaving that way because it didn't call WinHttpQueryDataAvailable before calling WinHttpReadData. WinHttpQueryDataAvailable would indicate how many bytes can be read immediately.

This fix changes the WinHttpResponseStream.Read* methods to use WinHttpQueryDataAvailable before calling WinHttpReadData.

Added both WinHttpHandler unit tests (helps with simulating/testing network errors) and HttpClientHandler functional tests (which will test x-plat).

Fixes dotnet/corefx#1825


Commit migrated from https://github.com/dotnet/corefx/commit/5386014a6b74a8d38010b244f9e9ced96df53b69
2015-10-30 10:39:32 -07:00
Hemanth Kapila 3801aebd66 Handling Invalid http response
CurlHandler to throw HttpRequestException if the HttpResponse message from the server has invalid format


Commit migrated from https://github.com/dotnet/corefx/commit/f95b1ec5d25c9046363bf85373060485f76c70a6
2015-10-30 22:20:30 +05:30
Eric Erhardt 9a1e6ee2fe Respond to PR feedback.
- Rename Interop.LibCurl to Interop.Http.
- Rename EasyPause to EasyUnpause, since that is what the method does.
- Removed usages of macros in native code.
- Changed managed libcurl constants to use enums.


Commit migrated from https://github.com/dotnet/corefx/commit/02d0b755cfb2b84fa27d48a064d5a5e6b81f9311
2015-10-29 22:01:03 -05:00
Eric Erhardt 5e7c3a08d2 Add shims for libcurl curl_easy_* functions.
Also adding PAL enums for any constants needed for those easy functions.


Commit migrated from https://github.com/dotnet/corefx/commit/6d307afc351901490891702a6a1d98551f3061fa
2015-10-29 18:53:43 -05:00
Eric Erhardt 3598370216 Add shims for Interop.libcurl_slist.cs functions.
Commit migrated from https://github.com/dotnet/corefx/commit/1a8f6cdc72d7281aeb520b251eb3dead3b011b96
2015-10-29 18:52:52 -05:00
bartonjs 0f9757fb70 Handle CURLE_UNKNOWN_OPTION when registering HTTPS callbacks on older versions of curl.
Prior to curl 7.39 the case label for CURLOPT_SSL_CTX_FUNCTION was compiled out, resulting in CURLE_UNKNOWN_OPTION.  In 7.39 they changed it to always present, but reporting CURLE_NOT_BUILT_IN when the backend SSL provider didn't support that callback.

The code was written based on the behavior of curl 7.43, so didn't know about the legacy behavioral difference.


Commit migrated from https://github.com/dotnet/corefx/commit/e5bf4763ce60bf50c36c2d473baaee76f09c740c
2015-10-29 14:45:18 -07:00
stephentoub ba797defff Replace Substring(...).Trim() with SubstringTrim(...)
System.Net.WebHeaderCollection already had a SubstringTrim helper that's used instead of Substring(...).Trim() to avoid first creating the substring and then trimming it, instead just offsetting the startIndex and length appropriately to do the Substring once.

I've factored this helper out into Common, added unit tests, cleaned it up a bit, and used it in several more places in System.Net.


Commit migrated from https://github.com/dotnet/corefx/commit/4e45e641c9d97c3a5d3b6fec4f6ffc33a2405fee
2015-10-28 12:29:59 -04:00
Stephen Toub e89a783d4b Merge pull request dotnet/corefx#4121 from bartonjs/unix_https_validation
Make Unix HttpClient use X509Chain instead of the default chain validator

Commit migrated from https://github.com/dotnet/corefx/commit/bd5ff4476937dc236585e9f7eef703f7dcd74979
2015-10-28 12:19:15 -04:00
Eric Erhardt 79b1558439 Merge pull request dotnet/corefx#4186 from eerhardt/ShimLibCurl
Add shim for libcurl version info.

Commit migrated from https://github.com/dotnet/corefx/commit/8924a5c367ce53c8bcb60cd44ccbf37e0a3fcf6a
2015-10-28 10:03:09 -05:00
Eric Erhardt be8a75b758 Add shim for libcurl version info.
Adding a native shim for curl_version_info and removing the managed constants that are no longer needed.


Commit migrated from https://github.com/dotnet/corefx/commit/18d5afe0c3b910e90a8d53807d1e29d104db06ba
2015-10-28 09:12:15 -05:00
stephentoub 2a4056ca09 Trim response headers in CurlHandler
Apply same header response trimming done by WinHttpHandler.
Fixes dotnet/corefx#4187

(At some point I'd like to go through and replace all Substring(...).Trim() calls with a more efficient SubstringTrim(...) that doesn't allocate an intermediate string.  But in the meantime, this addresses the problem.)


Commit migrated from https://github.com/dotnet/corefx/commit/a5053a14559ea30d224bf9f74892c86435d9166b
2015-10-27 22:47:56 -04:00
David Shulman 989c6f95bc Address PR feedback
Commit migrated from https://github.com/dotnet/corefx/commit/d9842e88757ebc10c472d96008ec6b627433219f
2015-10-27 17:26:12 -07:00
David Shulman a0239a721e Disable tests on Linux
Commit migrated from https://github.com/dotnet/corefx/commit/ae49b8e5428e509920b722912649e9a733cd1a3d
2015-10-27 16:51:09 -07:00
David Shulman 4b3de626c1 Removed commented-out code.
Commit migrated from https://github.com/dotnet/corefx/commit/79e3350eec6c9fdee9081f9d3dd8b42fe574ada3
2015-10-27 15:29:43 -07:00
David Shulman c8432253b4 Add HttpClient tests to support all HTTP verbs
Added tests for validating against all standard and custom HTTP verbs. These tests use the new networking test server.

Cosolidated some existing tests that were duplicative. More test porting and reorganzing will be done in later PRs.


Commit migrated from https://github.com/dotnet/corefx/commit/057f0a9bc938606f9e3a24a51f64f3a4fd9bbb55
2015-10-27 15:03:29 -07:00
bartonjs 2a30a1d8c8 Make CurlHandler use X509Chain to validate the chain.
libcurl+openssl defaults to just using X509_verify_cert, and the chain that came with the TLS handshake.

The X509Chain class has support for a user-defined trust list, downloading intermediate CA certs, and downloading CRLs (which isn't utilized in this change).

The existing approach was not doing CRL checking, and since the Unix X509Chain implementation does not support opportunistic CRL checking, this change leaves that functionality disabled.


Commit migrated from https://github.com/dotnet/corefx/commit/0ac85cd61e98ab684278dc3fe7a882623e207828
2015-10-27 09:52:17 -07:00
Hemanth Kapila 740209c940 Fix CurlHandler for http TRACE method
TRACE should not upload content.


Commit migrated from https://github.com/dotnet/corefx/commit/5875c5cc6f900941be8ac3ec21bd1cce53f4b3ae
2015-10-27 22:00:00 +05:30
Hemanth Kapila 3fd7c5ee4f Support for http delete and other methods for CurlHandler
Update CurlHandler to allow sending Http 'delete', 'options' and etc
Add two test cases for delete
Add two test cases for options

Support for other Http methods

Added tests for options as well


Commit migrated from https://github.com/dotnet/corefx/commit/20819227e708d42db9c3c4f8b7c0fd13180da777
2015-10-27 21:15:04 +05:30
David Shulman 7421388e81 WinHttpHandler: Fix POSTs with zero length content
While researching dotnet/corefx#3292, I discovered that POST'ing zero length content throws an exception. This was because we were calling WinHttpWriteData() and passing in a zero length for the buffer size. This returns an error back from WinHTTP.

We don't need to call WinHTTP APIs to write zero length data. We simply need to return a completed task back to the caller.

Added tests to verify the fix.


Commit migrated from https://github.com/dotnet/corefx/commit/0776e741430e83fe72bf4be544701f0eeddce042
2015-10-23 15:19:30 -07:00
stephentoub bc5024849b Fix CurlHandler deadlock with synchronous CopyToAsync
CurlHandler calls to HttpContext.CopyToAsync with a stream that CopyToAsync should write to asynchronously.  If, however, the call to CopyToAsync writes to it synchronously as part of the synchronous call to CopyToAsync, CurlHandler will deadlock.

As a precaution, we ensure that the CopyToAsync call is asynchronous from the perspective of CurlHandler.


Commit migrated from https://github.com/dotnet/corefx/commit/ebad2d3426af24201526263401fb010a78ee60bd
2015-10-23 08:24:18 -04:00
Stephen Toub 544c9f5354 Merge pull request dotnet/corefx#4078 from davidsh/requeststream_hang
Fix hang when writing request stream in WinHttpHandler

Commit migrated from https://github.com/dotnet/corefx/commit/e715350896154fc554f4d995c0c1294d6535ce08
2015-10-23 08:19:58 -04:00
David Shulman e4f15565ba Disable test on Linux
Commit migrated from https://github.com/dotnet/corefx/commit/775f07fac48137520e66b848fc9cf29428ebf07a
2015-10-22 20:13:39 -07:00
David Shulman 779afbe587 Fix hang when writing request stream in WinHttpHandler
WinHttpHandler was hanging due to blocking on the WinHTTP status callback thread. The blocking was coming from a task continuation resuming on the same thread and subsequently calling a blocking Stream.Write method in a custom HttpContent class being written onto the request stream.

Blocking is not allowed on the WinHTTP callback thread. So any task continuations need to occur on a different thread. The fix is to create the TaskCompletionSources to use RunContinuationsAsynchronously. This allows them to unblock the WinHTTP thread. Additionally, I added some missing ConfigureAwait(false) settings to some await'd operations.

Added a new test which uses a custom HttpContent class that uses a blocking Write() call when serializing onto the request stream.

Fix dotnet/corefx#4077


Commit migrated from https://github.com/dotnet/corefx/commit/babb7c6c65bf1e02dab667cbda80f0e24af21ed8
2015-10-22 16:44:06 -07:00
Matt Ellis f23deed6ba Merge 'upstream/master' into from-tfs
Conflicts:
	src/Common/test-runtime/project.lock.json
	src/System.Reflection.TypeExtensions/src/project.json
	src/System.Reflection.TypeExtensions/src/project.lock.json


Commit migrated from https://github.com/dotnet/corefx/commit/262aebcb35b4e0b09b1e08d37cdd70de3fb092e8
2015-10-22 13:15:56 -07:00
Hemanth Kapila 9bdfc50043 Test case for default state of HttpClientHandler.CookieContainer
Adding a new test case that verifies that httpClient does not send any cookie unless set


Commit migrated from https://github.com/dotnet/corefx/commit/7550e8bdd3af85f322fd309f412f919a6cd4f150
2015-10-22 20:22:19 +05:30
Hemanth Kapila bd0fcddf38 CurlHandler sending empty cookie
CurlHandler is sending an empty cookie unnecessarily. This commit fixes the behavior


Commit migrated from https://github.com/dotnet/corefx/commit/abc20ae4735e54c076e34795827af02ec7c9ce74
2015-10-22 11:27:54 +05:30