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 #624 from justcoding121/master
Browse files Browse the repository at this point in the history
Fix for #593 and #596
  • Loading branch information
honfika authored Aug 30, 2019
2 parents 7e0ad5c + ba42819 commit 53ba585
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
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

0 comments on commit 53ba585

Please sign in to comment.