Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements to HTTP web proxy #742

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified QuickFIXn/Transport/SocketInitiator.cs
100644 → 100755
Empty file.
8 changes: 4 additions & 4 deletions QuickFIXn/Transport/StreamFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ namespace QuickFix.Transport
/// </summary>
public 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
{
Expand All @@ -50,7 +50,7 @@ public 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";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You never did answer my original question: Will this new string work seamlessly with existing non-Squid users?

Why was it using destIp before if that wasn't really needed? Was that just the wrong way to do it?

byte[] buffer = Encoding.ASCII.GetBytes(proxyMsg);
byte[] buffer12 = new byte[500];
socketThruProxy.Send(buffer, buffer.Length, 0);
Expand Down Expand Up @@ -79,7 +79,7 @@ public static Stream CreateClientStream(IPEndPoint endpoint, SocketSettings sett
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.
Expand Down
Loading