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

beta #726

Merged
merged 2 commits into from
Dec 28, 2019
Merged

beta #726

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
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