Skip to content
This repository was archived by the owner on Jul 9, 2023. It is now read-only.
Merged
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
16 changes: 16 additions & 0 deletions src/Titanium.Web.Proxy/Extensions/UriExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;

namespace Titanium.Web.Proxy.Extensions
{
internal static class UriExtensions
{
internal static string GetOriginalPathAndQuery(this Uri uri)
{
string leftPart = uri.GetLeftPart(UriPartial.Authority);
if (uri.OriginalString.StartsWith(leftPart))
return uri.OriginalString.Substring(leftPart.Length);

return uri.IsWellFormedOriginalString() ? uri.PathAndQuery : uri.GetComponents(UriComponents.PathAndQuery, UriFormat.Unescaped);
}
}
}
3 changes: 1 addition & 2 deletions src/Titanium.Web.Proxy/Http/HttpWebClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ internal async Task SendRequest(bool enable100ContinueBehaviour, bool isTranspar
}
else
{
var uri = Request.RequestUri;
url = uri.IsWellFormedOriginalString() ? uri.PathAndQuery : uri.GetComponents(UriComponents.PathAndQuery, UriFormat.Unescaped);
url = Request.RequestUri.GetOriginalPathAndQuery();
}

// prepare the request & headers
Expand Down
3 changes: 3 additions & 0 deletions src/Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,9 @@ private async Task<TcpServerConnection> createServerConnection(string remoteHost
{
throw new Exception($"Could not establish connection to {hostname}", e);
}

// dispose the current TcpClient and try the next address
tcpClient?.Dispose();
}
}

Expand Down