Commit Graph
570 Commits
Author SHA1 Message Date
David Shulman 2ae1d2c874 Update System.Net tests to use newer corefx-testdata PFX files (dotnet/corefx#29724)
Updated PFX files were checked into corefx-testdata repro via
https://github.com/dotnet/corefx-testdata/pull/24. This PR removed
the friendly name attribute from the private key. This fixes the
problem in Windows dealing with parallel PFX import.

This PR updates the System.Net.* tests to use the updated corefx-testdata package.

Closes dotnet/corefx#23341
Contributes to dotnet/corefx#9543

Commit migrated from https://github.com/dotnet/corefx/commit/84883052ef0f720a8befdc8525db50c9544227d5
2018-05-16 11:42:46 -07:00
Stephen Toub c8e7b2312b Add missing awaits to XmlTextReaderImplAsync (dotnet/corefx#29518)
* Comment on awaits that don't need ConfigureAwait(false)

- Add comments to several awaits on tasks where ConfigureAwait is unnecessary for a variety of reasons
- Rather than commenting, change one await to GetAwaiter().GetResult() where we know the task is already completed (rather than just commenting to that effect)

* Add missing awaits to XmlTextReaderImplAsync


Commit migrated from https://github.com/dotnet/corefx/commit/b758c3b1f1293ada2e46f9e221be0b392838cc41
2018-05-04 16:08:59 -04:00
Dan Friedman 33591df321 Clean dead code System.Net* (dotnet/corefx#29302)
* Clean dead code in System.Net

* More cleaning

* Clean dead code for HttpListener

* Clean dead code for Mail

* Clean dead code in Http

* Clean dead code for NetworkInformation

* Clean more dead code

* Various fixes

* Build fix

* Restore field

* var -> string


Commit migrated from https://github.com/dotnet/corefx/commit/71cc1ae8ba02b7b71878cb69a50c667c8ed0f50f
2018-05-01 16:49:12 -07:00
Caesar Chen dc7affffaf Fix ClientWebSocket error message when endpoint is not a real websocket (dotnet/corefx#29159)
* fix clientwebsocket error message

* address feedback

* fix comment


Commit migrated from https://github.com/dotnet/corefx/commit/0c15e758b797bded4a058b397e0a520961a84c6a
2018-04-18 09:03:45 -07:00
Stephen Toub 30cf8987ce Remove buffer argument from WebSocket.CreateFromStream (dotnet/corefx#28649)
Commit migrated from https://github.com/dotnet/corefx/commit/bf38b7b8c56e7fbe10796dcfa1918a36377a1cd6
2018-03-30 14:23:56 -07:00
Stephen Toub c62e1d8f06 Reduce buffering in ManagedWebSocket.ReceiveAsync (dotnet/corefx#28577)
* Change SocketsHttpHandler's 101 response stream to buffer response reads

The connection already has a buffer; use it.

* Reduce buffering in ManagedWebSocket.ReceiveAsync

Today we use a big-ish receive buffer, reading all data into the receive buffer and then copying from there into the caller-provided destination buffer.  With this change, we assume that the underlying stream is providing the desired level of buffering, and thus only use a buffer small enough to handle message headers and control payloads (the latter for simplicity, as no caller-supplied buffer is available there).

* Change ClientWebSocket to avoid creating a large buffer


Commit migrated from https://github.com/dotnet/corefx/commit/06aa6f0ce4cdf78985f029f218007a7d55f8965f
2018-03-30 09:53:26 -07:00
Stephen Toub 88da6077e1 Add WebSocket test for zero-byte receives (dotnet/corefx#28579)
Commit migrated from https://github.com/dotnet/corefx/commit/21947fbd29845d6fea9c5576991b6debc995e0f7
2018-03-28 23:11:51 -07:00
Caesar Chen bbfe5af55e enable test (dotnet/corefx#28481)
Commit migrated from https://github.com/dotnet/corefx/commit/1d107ad2e499bda7de6974f83314ebfe8b38f7b5
2018-03-28 11:25:21 -07:00
Alexander Radchenko cb47fdd588 Fixed netfx System.Net.WebSockets.Client.Tests fails on non-English Windows (dotnet/corefx#28380)
Commit migrated from https://github.com/dotnet/corefx/commit/4e3476bcee357443fbd1668269cf33276e310c97
2018-03-22 22:59:46 -04:00
Caesar Chen 162fd4fcf7 Make ClientWebSocket always use CONNECT tunneling through a proxy (dotnet/corefx#28150)
* make non-secure websocket use CONNECT tunnel through proxy

* add test

* address pr feedback


Commit migrated from https://github.com/dotnet/corefx/commit/cad146596eb4f64ae81fc7db17335a6fb12e0b3b
2018-03-22 09:31:24 -07:00
Stephen Toub cb16c44b05 Expose ClientWebSocketOptions.RemoteCertificateValidationCallback (dotnet/corefx#28141)
* Expose ClientWebSocketOptions.RemoteCertificateValidationCallback

* Address PR feedback

* Address PR feedback


Commit migrated from https://github.com/dotnet/corefx/commit/c008bb5c791c930b1a5a8cb4bb160f6dc675240e
2018-03-19 19:12:32 -04:00
Caesar Chen 5710d3bdca enable test (dotnet/corefx#28106)
Commit migrated from https://github.com/dotnet/corefx/commit/e9fb978f6a77d9758a47f2e1cfd00c73f1b5b9e9
2018-03-15 17:05:43 -07:00
David Shulman 2969354735 Add tests for ClientWebSocket connections thru a proxy (dotnet/corefx#28031)
Created new tests for verifying ClientWebSocket connections
end-to-end thru a proxy.

Opened new issues dotnet/corefx#28024 and dotnet/corefx#28027 which cause the new tests to fail.

Fixes dotnet/corefx#26957

Commit migrated from https://github.com/dotnet/corefx/commit/02c3892380a392458a4d1f41c53ce2048cb6681d
2018-03-14 09:45:39 -07: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
Stephen Toub fd01dc8c39 Use shared SocketsHttpHandler for some ClientWebSocket options (dotnet/corefx#27994)
* Use shared SocketsHttpHandler for some ClientWebSocket options

Currently we're creating a new SocketsHttpHandler for each ClientWebSocket.  This change makes it so that if mostly default options are used (namely no credentials, no proxy, no cookies, and no client certificates), we'll use a shared handler instance.

* Make ClientWebSocketOptions.Proxy non-null by default

netfx's ClientWebSocketOptions.Proxy defaults to a system-default proxy.  It can then be set to null to mean "no proxy" or to another proxy.  This changes netcoreapp's Proxy to match as closely as possible.

It also then fixes up a few other settings on SocketsHttpHandler:
- UseDefaultCredentials wasn't being factored in.  On netfx, UseDefaultCredentials takes precedence over Credentials, so this does the same.
- UseCookies should be true iff Cookies is non-null.

Finally, removed Outerloop from some tests that did not need to be, as they didn't actually involve making external requests, and deleted some dead test code.


Commit migrated from https://github.com/dotnet/corefx/commit/d4853e2cfd69cda68c0b17fd54b6c7d2d48b7f98
2018-03-13 14:03:19 -04:00
Stephen Toub 52648185cb Dispose of the SocketsHttpHandler used in WebSocketHandle.Managed (dotnet/corefx#27900)
Commit migrated from https://github.com/dotnet/corefx/commit/649ddbcefcc53e99219a4fc483b23c70880d801e
2018-03-09 13:07:05 -05:00
Eric St. John 98c0015605 Update SLNs and projects to be in sync with configurations
Commit migrated from https://github.com/dotnet/corefx/commit/8ce7e620e1b5001be002598f4d10d4becdd77a49
2018-03-08 08:25:31 -08:00
Stephen Toub 62ff1478db Fix NullReferenceException when using client certs with ClientWebSocket (dotnet/corefx#27777)
Commit migrated from https://github.com/dotnet/corefx/commit/e9d0a64f1d275ef0cb41b3812d6226ac1a45cb49
2018-03-06 19:14:42 -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
Max Kerr ef39ea4c98 Update WebSocket status when the underlying connection is closed (dotnet/corefx#27556)
This fix addresses a behavior difference between the new managed WebSocket implementation and the old Windows only version.

When the underlying connection is closed, we need to also update the state of the WebSocket to show that it has been aborted. All of the code to do this was already written, it just needed to be called in one additional place.

Fixes dotnet/corefx#26219


Commit migrated from https://github.com/dotnet/corefx/commit/594a7f2a72dca255bb8e09613d3dcbb2499215de
2018-02-28 13:41:43 -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
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
Stephen Toub f8e6f41b81 Clear initlocals in a bunch of assemblies (dotnet/corefx#26993)
* Clear initlocals in a bunch of assemblies

Sets
```XML
<ILLinkClearInitLocals>true</ILLinkClearInitLocals>
```
for the assemblies:
    - System.IO.FileSystem
    - System.IO.Pipes
    - System.Memory
    - System.Net.Http
    - System.Net.Http.WinHttpHandler
    - System.Net.NameResolution
    - System.Net.NetworkInformation
    - System.Net.Primitives
    - System.Net.Requests
    - System.Net.Security
    - System.Net.Sockets
    - System.Net.WebSockets
    - System.Net.WebSockets.Client
    - System.Net.WebSockets.WebSocketsProtocol
    - System.Private.Uri
    - System.Runtime
    - System.Runtime.Extensions

Eventually we'd ideally set the flag for the whole repo; these are just the ones I audited thus far.  In a few cases I had to make code changes to adapt, where the code was expecting stackallocs to be cleared.  I also looked at a few other projects (System.Collections, System.Runtime.Numerics) where there were more significant dependencies on clearing and I decided to leave those for later.

* Disable ILLinkClearInitLocals running on Unix until it works there


Commit migrated from https://github.com/dotnet/corefx/commit/f0a032e4a1c8a848574a5db3e69e8a6fa0aae91e
2018-02-13 06:30:25 -05:00
Geoff Kizer 3a5fbcf1c2 add protocol tests for cookie handling
Commit migrated from https://github.com/dotnet/corefx/commit/750b29bbb1433ad5d4c3727217192dddbef90eef
2018-02-09 00:37:09 -08: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
Stephen Toub 3e942132d9 Fix ManagedHandler env var / AppContext handling (dotnet/corefx#26763)
* Fix ManagedHandler env var / AppContext handling

* Update two names

* Update README.md


Commit migrated from https://github.com/dotnet/corefx/commit/473a4cf05c28f95d8a93b826647f755dbdec8728
2018-02-01 22:04:16 -05:00
Lakshmi Priya Sekar 7b8085b573 Use ManagedWebSocket implementation everywhere except uap.
Commit migrated from https://github.com/dotnet/corefx/commit/70f41f974d2b9aaa25e10d897a647bd2d3b1c103
2018-01-18 15:26:23 -08:00
Ahson Khan 7886be085d Convert uses of the Dangerous APIs to use MemoryMarshal.GetReference (dotnet/corefx#25936)
* Convert uses of the Dangerous APIs to use MemoryMarshal.GetReference

* Fix unresolved merge conflict.

* Add using directive

* Add missing using directives.

* Add references to System.Memory


Commit migrated from https://github.com/dotnet/corefx/commit/40cbd5636851093309b841db4d53af369b7ef1c6
2017-12-21 11:05:06 -08:00
Santiago Fernandez Madero c077e72880 Ensure build of netcoreapp vertical of CoreFx can be done without past packages (dotnet/corefx#25921)
* Add System.Drawing.Common to netcoreapp vertical

* Make System.Data.Odbc be able to build for netcoreapp vertical

* Add netcoreapp to System.Diagnostics.PerformanceCounter

* Add netcoreapp to System.Diagnostics.EventLog

* Run UpdateVSConfigurations

* Change Contains('netcoreapp') to StartsWith('netcoreapp')

* Include netcoreapp.depproj only when BuildAllConfigurations == true

* Change tests to netcoreapp from netcoreapp2.0 for vertical


Commit migrated from https://github.com/dotnet/corefx/commit/edacccb1cd6ecf7d36cd2379df8dd609ae0eb9a4
2017-12-18 17:20:36 -06:00
Ahson Khan 9de80f2b5a Reference Unsafe APIs from CoreLib in System.Memory (dotnet/corefx#25929)
* Reference Unsafe APIs from CoreLib in System.Memory

* Add reference to System.Memory for System.Net.Sockets.

* Remove unused references to S.R.CS.Unsafe.

* Used fixed instead of Unsafe API


Commit migrated from https://github.com/dotnet/corefx/commit/79d708b2faf8a75089b1873fbb101b0a957c1fbd
2017-12-15 23:36:33 -08:00
Stephen Toub 2627119b05 Fix subprotocol check in WebSocketHandle.Managed (dotnet/corefx#25645)
Commit migrated from https://github.com/dotnet/corefx/commit/ac33201c4062437bd907bed24dea85e6c38d92ff
2017-12-01 23:16:09 -05:00
David Shulman 19ef688da1 Cleanup Windows 10 version detection (dotnet/corefx#25052)
* Cleanup Windows 10 version detection

Windows 10 Version 1709 ("Fall Creators Update") has been released. This
PR cleans up the version detection to use the latest RTM build numbers
and removes obsolete InsiderPreview detection for those tests.

Also, removed ActiveIssue for tests that are now fixed due to Windows 10
fixes.

Fixes dotnet/corefx#22187

* Addressed feedback


Commit migrated from https://github.com/dotnet/corefx/commit/ac410223aa763a0f67880815057ee1bfe0f4cb6e
2017-11-04 11:09:38 -07:00
Stephen Toub 54c1d578d8 Mark applicable structs as readonly
Commit migrated from https://github.com/dotnet/corefx/commit/54e889a7c71bf22f9f1ef244a9d040fee64c74d5
2017-11-03 09:48:47 -04:00
Stephen Toub c157846c8f Fix a few WebSocketHandle.Managed issues (dotnet/corefx#25010)
- At least until socket send/receives respect cancellation, we need to poll for cancellation after the handler's SendAsync completes.
- We're unnecessarily allocating another CTS if no external cancellation was provided.
- We're not disposing of the response object in the case of an error after SendAsync completes.

Commit migrated from https://github.com/dotnet/corefx/commit/baf2128a7cdf4a7638be1e86a6fc18651f3945d3
2017-11-02 10:35:38 -04:00
Stano Peťko b4e7a56257 Remove dead code from System.Net.WebSocket.Client (dotnet/corefx#24932)
* Deleted dead code from System.Neet.WebSocket.Client.

* Reverted changes in WinHttpWebSocketCallback.


Commit migrated from https://github.com/dotnet/corefx/commit/7a3d591c8e4e308c32e9f4932eaf8fa9ed1d760b
2017-10-30 15:04:15 -04:00
Stephen Toub dfced62bc2 Add ManagedHandler support for cancelling connect operations (dotnet/corefx#24873)
Commit migrated from https://github.com/dotnet/corefx/commit/0e517d15d2a90aceffdd6bbc6c1de80b8582a154
2017-10-30 15:02:27 -04:00
Stephen Toub e5ddad9e15 Merge pull request dotnet/corefx#24846 from stephentoub/websockets_memory
Add `Memory<byte>` support to WebSockets

Commit migrated from https://github.com/dotnet/corefx/commit/1cce3631a78c11271f34762253b3a3273a8207fc
2017-10-30 09:35:08 -04:00
Stephen Toub 087ef535f4 Use the Host header for the SSL handshake
Commit migrated from https://github.com/dotnet/corefx/commit/5ecea8ff47c03a073a77916a9c7d1d806f8c7ce3
2017-10-25 13:40:03 -04:00
Stephen Toub 22b5633f97 Override Memory-based ReceiveAsync on WinHttpWebSocket
Commit migrated from https://github.com/dotnet/corefx/commit/98d53f272c58b4df9ce997d816d853ddff43e7d8
2017-10-24 17:23:10 -04:00
Stephen Toub 2941eee4df Add Memory-based Send/ReceiveAsync methods to WebSocket
Commit migrated from https://github.com/dotnet/corefx/commit/e2a978a526afc969d6c19cd9e8562821a038d992
2017-10-24 17:20:46 -04:00
Stephen Toub 0905009c92 Use WebSocket.CreateFromStream in System.Net.WebSockets.Client on Unix
Commit migrated from https://github.com/dotnet/corefx/commit/905aaa69de299ca3ef46e7129764e6a94ccfbe97
2017-10-24 17:15:25 -04:00
Stephen Toub 1457854fb7 Address PR feedback
- Have ClientWebSocket change the scheme from http{s} -> ws{s} instead of having HttpClient accept ws{s} urls.
- Use a duplex response stream only when the status code is 101
- Disable a test that relies on connection opening being cancelable


Commit migrated from https://github.com/dotnet/corefx/commit/518ea1c2f8ad882c9829c8c35d27d92063ac67f7
2017-09-28 21:08:28 -04:00
Stephen Toub 6dcb0c35a4 Use ManagedHandler in managed ClientWebSocket
ClientWebSocket's managed implementation currently has its own basic Socket-based code for establishing a websocket connection.  This change switches it to use ManagedHandler instead, and in doing so benefits from improvements made to ManagedHandler thus far and in the future.  For example, currently ManagedWebSocket doesn't support ClientWebSocketOptions.Proxy or ClientWebSocketOptions.Credentials, but since ManagedHandler does, now ManagedWebSocket does, too.


Commit migrated from https://github.com/dotnet/corefx/commit/db9f342cc43e0096b42d4d6d008c095da2bb8cfa
2017-09-28 21:08:28 -04:00
Stephen Toub f18c6b1018 Make several allocations from ClientWebSocketOptions lazy
Commit migrated from https://github.com/dotnet/corefx/commit/87ae016da78b9a29be33cc17f076b32c57c2a699
2017-09-28 21:08:27 -04:00
Stephen Toub 6ca3d41d49 Fix several Connect test's dependence on ReceiveAsync returning complete message
There's no guarantee that WebSocket.ReceiveAsync will return a complete message; in the extreme, a message can contain long.MaxValue bytes but the API only allows you to retrieve ~int.MaxValue at a time, but even way below that, it's common for ReceiveAsync to return the data it has available rather than gathering up all of the data from the message.  However, several of the ConnectTest tests were depending on the full-message behavior.  This commit fixes that.


Commit migrated from https://github.com/dotnet/corefx/commit/ffaf5375c00622b285997bc9626c042b9d64195c
2017-09-28 21:08:26 -04:00
Stephen Toub 0b0e20a963 Reduce running time of KeepAlive_LongDelayBetweenSendReceives_Succeeds test
60 seconds is annoyingly long when trying to iterate.  Reduced to 10.


Commit migrated from https://github.com/dotnet/corefx/commit/941c4c80f0d25b34808d19adc7f8556107a88718
2017-09-28 21:08:23 -04:00
Andrius Bentkus d443114434 Do not use zero width spaces (dotnet/corefx#24069)
Fixes dotnet/corefx#24068

Commit migrated from https://github.com/dotnet/corefx/commit/13db0aefa78577e9c9fd5574103178383c16508e
2017-09-15 07:14:33 -07:00
David Shulman 852d0050d8 Disable brittle WebSockets.Client test (dotnet/corefx#23920)
System.Net.WebSockets.Client.Tests.KeepAliveTest/KeepAlive_LongDelayBetweenSendReceives_Succeeds

"System.Net.WebSockets.WebSocketException : The WebSocket is in an
invalid state ('Aborted') for this operation. Valid states are: 'Open,
CloseReceived, CloseSent, Closed'"

dotnet/corefx#23204

Commit migrated from https://github.com/dotnet/corefx/commit/d075c7d1ca07657a3c4f71a94dd944d9ab28d31a
2017-09-09 18:38:32 -07:00
David Shulman c3dbc2406e Disable some networking tests
Disabling tests.
dotnet/corefx#23765 dotnet/corefx#23766 dotnet/corefx#23767 dotnet/corefx#23768 dotnet/corefx#23769 dotnet/corefx#23770 dotnet/corefx#23771


Commit migrated from https://github.com/dotnet/corefx/commit/acafae51592f7e09fba003a3684d550dba155a2e
2017-09-02 16:50:54 -07:00
Brian Chavez 88875187b0 XML doc spelling corrections - D through H. 🚿 (dotnet/corefx#23638)
Commit migrated from https://github.com/dotnet/corefx/commit/a27929935d2782cdc3e7be21653e8c4530274c6f
2017-08-29 17:10:01 -07:00