Skip to content
This repository has been archived by the owner on Jul 9, 2023. It is now read-only.

Commit

Permalink
Merge pull request #726 from justcoding121/master
Browse files Browse the repository at this point in the history
beta
  • Loading branch information
honfika authored Dec 28, 2019
2 parents f3528b7 + 27791e0 commit fce77d7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ public ProxyTestController()
await writeToConsole(exception.Message, ConsoleColor.Red);
}
};

proxyServer.TcpTimeWaitSeconds = 10;
proxyServer.ConnectionTimeOutSeconds = 15;
proxyServer.ReuseSocket = false;
proxyServer.EnableConnectionPool = false;
proxyServer.ForwardToUpstreamGateway = true;
proxyServer.CertificateManager.SaveFakeCertificates = true;
//proxyServer.ProxyBasicAuthenticateFunc = async (args, userName, password) =>
Expand Down
7 changes: 6 additions & 1 deletion src/Titanium.Web.Proxy/Helpers/HttpStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,12 @@ private async Task copyBodyChunkedAsync(IHttpStreamWriter writer, Action<byte[],
{
while (true)
{
string chunkHead = (await ReadLineAsync(cancellationToken))!;
string? chunkHead = await ReadLineAsync(cancellationToken);
if (chunkHead == null)
{
return;
}

int idx = chunkHead.IndexOf(";");
if (idx >= 0)
{
Expand Down
7 changes: 6 additions & 1 deletion src/Titanium.Web.Proxy/RequestHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ await HeaderParser.ReadHeaders(clientStream, args.HttpClient.Request.Headers,
if (part1 & part2)
{
//connection is closed
await tcpConnectionFactory.Release(connection, true);
connection = null;
}
}
Expand Down Expand Up @@ -297,7 +298,11 @@ private async Task<RetryResult> handleHttpSessionRequest(SessionEventArgs args,

if (args.HttpClient.Request.UpgradeToWebSocket)
{
args.HttpClient.ConnectRequest!.TunnelType = TunnelType.Websocket;
// connectRequest can be null for SOCKS connection
if (args.HttpClient.ConnectRequest != null)
{
args.HttpClient.ConnectRequest!.TunnelType = TunnelType.Websocket;
}

// if upgrading to websocket then relay the request without reading the contents
await handleWebSocketUpgrade(args, args.ClientStream, connection, cancellationTokenSource, cancellationToken);
Expand Down

0 comments on commit fce77d7

Please sign in to comment.