Commit ce0bba9b authored by Honfika's avatar Honfika

allow to terminate server connection

parent bb2d9b0e
...@@ -46,7 +46,6 @@ namespace Titanium.Web.Proxy ...@@ -46,7 +46,6 @@ namespace Titanium.Web.Proxy
try try
{ {
string connectHostname = null; string connectHostname = null;
ConnectRequest connectRequest = null; ConnectRequest connectRequest = null;
//Client wants to create a secure tcp tunnel (probably its a HTTPS or Websocket request) //Client wants to create a secure tcp tunnel (probably its a HTTPS or Websocket request)
...@@ -297,7 +296,7 @@ namespace Titanium.Web.Proxy ...@@ -297,7 +296,7 @@ namespace Titanium.Web.Proxy
string httpCmd = await clientStreamReader.ReadLineAsync(); string httpCmd = await clientStreamReader.ReadLineAsync();
if (string.IsNullOrEmpty(httpCmd)) if (string.IsNullOrEmpty(httpCmd))
{ {
break; return;
} }
var args = new SessionEventArgs(BufferSize, endPoint, ExceptionFunc) var args = new SessionEventArgs(BufferSize, endPoint, ExceptionFunc)
...@@ -364,7 +363,7 @@ namespace Titanium.Web.Proxy ...@@ -364,7 +363,7 @@ namespace Titanium.Web.Proxy
//send the response //send the response
await clientStreamWriter.WriteResponseAsync(args.WebSession.Response); await clientStreamWriter.WriteResponseAsync(args.WebSession.Response);
break; return;
} }
if (!isTransparentEndPoint) if (!isTransparentEndPoint)
...@@ -397,7 +396,7 @@ namespace Titanium.Web.Proxy ...@@ -397,7 +396,7 @@ namespace Titanium.Web.Proxy
if (!response.KeepAlive) if (!response.KeepAlive)
{ {
break; return;
} }
continue; continue;
...@@ -450,16 +449,22 @@ namespace Titanium.Web.Proxy ...@@ -450,16 +449,22 @@ namespace Titanium.Web.Proxy
(buffer, offset, count) => { args.OnDataReceived(buffer, offset, count); }, (buffer, offset, count) => { args.OnDataReceived(buffer, offset, count); },
ExceptionFunc); ExceptionFunc);
break; return;
} }
//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.
await HandleHttpSessionRequestInternal(connection, args); await HandleHttpSessionRequestInternal(connection, args);
if (args.WebSession.ServerConnection == null)
{
//server connection was closed
return;
}
//if connection is closing exit //if connection is closing exit
if (!response.KeepAlive) if (!response.KeepAlive)
{ {
break; return;
} }
} }
catch (Exception e) when (!(e is ProxyHttpException)) catch (Exception e) when (!(e is ProxyHttpException))
......
...@@ -57,6 +57,11 @@ namespace Titanium.Web.Proxy ...@@ -57,6 +57,11 @@ namespace Titanium.Web.Proxy
//syphon out the response body from server before setting the new body //syphon out the response body from server before setting the new body
await args.SyphonOutBodyAsync(false); await args.SyphonOutBodyAsync(false);
} }
else
{
args.WebSession.ServerConnection.Dispose();
args.WebSession.ServerConnection = null;
}
return; return;
} }
......
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