Commit 7e4c20f8 authored by justcoding121's avatar justcoding121 Committed by justcoding121

#267 create new connection when hostname changes

parent 27bba852
...@@ -6,6 +6,7 @@ using System.Net; ...@@ -6,6 +6,7 @@ using System.Net;
using System.Net.Security; using System.Net.Security;
using System.Net.Sockets; using System.Net.Sockets;
using System.Security.Authentication; using System.Security.Authentication;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Titanium.Web.Proxy.EventArguments; using Titanium.Web.Proxy.EventArguments;
using Titanium.Web.Proxy.Exceptions; using Titanium.Web.Proxy.Exceptions;
...@@ -354,6 +355,14 @@ namespace Titanium.Web.Proxy ...@@ -354,6 +355,14 @@ namespace Titanium.Web.Proxy
{ {
connection = await GetServerConnection(args); connection = await GetServerConnection(args);
} }
//create a new connection if hostname changes
else if (!connection.HostName.Equals(args.WebSession.Request.RequestUri.Host,
StringComparison.OrdinalIgnoreCase))
{
connection.Dispose();
Interlocked.Decrement(ref serverConnectionCount);
connection = await GetServerConnection(args);
}
//construct the web request that we are going to issue on behalf of the client. //construct the web request that we are going to issue on behalf of the client.
disposed = await HandleHttpSessionRequestInternal(connection, args, false); disposed = await HandleHttpSessionRequestInternal(connection, args, false);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment