From c10db5b56c727561e30bbc0b11010dc464e848d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marie=20P=C3=ADchov=C3=A1?= Date: Sat, 15 Aug 2020 11:11:46 +0200 Subject: [PATCH] Fix sync ConnectHelper.Connect Redo of https://github.com/dotnet/runtime/pull/39514 --- .../src/System/Net/Http/SocketsHttpHandler/ConnectHelper.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectHelper.cs b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectHelper.cs index 587913e2289335..841cce7adbba3f 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectHelper.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectHelper.cs @@ -62,6 +62,9 @@ public static Connection Connect(string host, int port, CancellationToken cancel { socket.Connect(new DnsEndPoint(host, port)); } + + // Since we only do GracefulShutdown in SocketsHttpHandler code, Connection.FromStream() should match SocketConnection's behavior: + return Connection.FromStream(new NetworkStream(socket, ownsSocket: true), localEndPoint: socket.LocalEndPoint, remoteEndPoint: socket.RemoteEndPoint); } catch (SocketException se) { @@ -77,9 +80,6 @@ public static Connection Connect(string host, int port, CancellationToken cancel socket.Dispose(); throw CreateWrappedException(e, host, port, cancellationToken); } - - // Since we only do GracefulShutdown in SocketsHttpHandler code, Connection.FromStream() should match SocketConnection's behavior: - return Connection.FromStream(new NetworkStream(socket, ownsSocket: true), localEndPoint: socket.LocalEndPoint, remoteEndPoint: socket.RemoteEndPoint); } public static ValueTask EstablishSslConnectionAsync(SslClientAuthenticationOptions sslOptions, HttpRequestMessage request, bool async, Stream stream, CancellationToken cancellationToken)