diff --git a/QuickFIXn/Transport/StreamFactory.cs b/QuickFIXn/Transport/StreamFactory.cs index 66117a7d0..4bc22d03d 100644 --- a/QuickFIXn/Transport/StreamFactory.cs +++ b/QuickFIXn/Transport/StreamFactory.cs @@ -14,12 +14,12 @@ namespace QuickFix.Transport /// internal static class StreamFactory { - private static Socket? CreateTunnelThruProxy(string destIp, int destPort) + private static Socket? CreateTunnelThruProxy(string destIp, int destPort, string destHostName) { string destUriWithPort = $"{destIp}:{destPort}"; UriBuilder uriBuilder = new UriBuilder(destUriWithPort); Uri destUri = uriBuilder.Uri; - IWebProxy webProxy = WebRequest.GetSystemWebProxy(); + IWebProxy webProxy = WebRequest.DefaultWebProxy ?? WebRequest.GetSystemWebProxy(); try { @@ -44,7 +44,7 @@ internal static class StreamFactory Socket socketThruProxy = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); socketThruProxy.Connect(proxyEndPoint); - string proxyMsg = $"CONNECT {destIp}:{destPort} HTTP/1.1 \n\n"; + string proxyMsg = $"CONNECT {destHostName}:{destPort} HTTP/1.1\nHost: {destHostName}:{destPort}\n\n"; byte[] buffer = Encoding.ASCII.GetBytes(proxyMsg); byte[] buffer12 = new byte[500]; socketThruProxy.Send(buffer, buffer.Length, 0); @@ -73,7 +73,7 @@ internal static Stream CreateClientStream(IPEndPoint endpoint, SocketSettings se if (!settings.SocketIgnoreProxy) { // If system has configured a proxy for this config, use it. - socket = CreateTunnelThruProxy(endpoint.Address.ToString(), endpoint.Port); + socket = CreateTunnelThruProxy(endpoint.Address.ToString(), endpoint.Port, settings.ServerCommonName); } // No proxy. Set up a regular socket. diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 364322262..3124a39f9 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -50,6 +50,7 @@ What's New * #516 - remove ability to toggle Session-enable via HttpServer because it never really worked (gbirchmeier) * #913/#741 - new FieldMap.ReadGroups for iterating on groups (NoviProg/gbirchmeier) * #914 - Optimize MessageCracker.IsHandlerMethod (vasily-balansea) +* #742 - Improvements to HTTP web proxy (IanLeeClaxton) ### v1.12.0