* 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
* 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.
Fixesdotnet/corefx#22187
* Addressed feedback
Commit migrated from https://github.com/dotnet/corefx/commit/ac410223aa763a0f67880815057ee1bfe0f4cb6e
With these changes, the UWP implementation of ClientWebSocket.ConnectAsync takes the ClientCertificates member of the app-provided ClientWebSocketOptions into account. The first client cert that can be successfully converted into a WinRT client cert (if any) is configured on the underlying WinRT MessageWebSocket instance, leading to the cert being used for mutual TLS authentication when establishing connections with WSS endpoints.
This fix leverages WinRT APIs that are only present since Windows 10 Insider Preview Build 16215, so API presence checks are in place.
Fixesdotnet/corefx#21393
Commit migrated from https://github.com/dotnet/corefx/commit/0c478304177f038af958959f1d106522b77bce26
Adds to System.Net.WebSockets:
- WebSocketException deriving from Win32Exception
- WebSocketException.ctor()
- WebSocket.DefaultKeepAliveInterval
- WebSocket.CreateClientBuffer
- WebSocket.CreateClientWebSocket
- WebSocket.CreateServerBuffer
- WebSocket.IsApplicationTargeting45
- WebSocket.IsStateTerminal
- WebSocket.ReisterPrefixes
- WebSocket.ThrowOnInvalidState
- WebSocketContext.RequestUri
- WebSocketContext.Headers
- WebSocketContext.Origin
- WebSocketContext.SecWebSocketProtocols
- WebSocketContext.SecWebSocketKey
- WebSocketContext.CookieCollection
- WebsocketContext.User
- WebSocketContext.IsAuthenticated
- WebSocketContext.IsLocal
- WebSocketContext.IsSecureConnection
- WebSocketContext.WebSocket
(Several of these members just throw PlatformNotSupportedException. Others have a different implementation than on desktop but something that's reasonable for corefx given the rest of the implementation's differences, e.g. limits on buffer sizes.)
Adds to System.Net.WebSockets.Client:
- ClientWebSocketOptions.UseDefaultCredentials
- ClientWebSocketOptions.SetBuffer(int, int)
- ClientWebSocketOptions.SetBuffer(int, int, ArraySegment<byte>)
As part of this, I also:
- Updated ClientWebSocketOptions.KeepAliveInterval to default to 30 seconds, as it does on desktop, rather than defaulting to 0.
- Updated the managed websockets implementation to take the ClientWebSocketOptions buffer information into account, in particular the receive buffer size and the buffer itself (as long as offset and count don't represent a subset, which would have been a more intrusive change to support).
Commit migrated from https://github.com/dotnet/corefx/commit/c97a2c7ac8ff5a4473348adf2ba6ca6a141de116