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

Commit 53ba585

Browse files
authored
Merge pull request #624 from justcoding121/master
Fix for #593 and #596
2 parents 7e0ad5c + ba42819 commit 53ba585

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System;
2+
3+
namespace Titanium.Web.Proxy.Extensions
4+
{
5+
internal static class UriExtensions
6+
{
7+
internal static string GetOriginalPathAndQuery(this Uri uri)
8+
{
9+
string leftPart = uri.GetLeftPart(UriPartial.Authority);
10+
if (uri.OriginalString.StartsWith(leftPart))
11+
return uri.OriginalString.Substring(leftPart.Length);
12+
13+
return uri.IsWellFormedOriginalString() ? uri.PathAndQuery : uri.GetComponents(UriComponents.PathAndQuery, UriFormat.Unescaped);
14+
}
15+
}
16+
}

src/Titanium.Web.Proxy/Http/HttpWebClient.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,7 @@ internal async Task SendRequest(bool enable100ContinueBehaviour, bool isTranspar
104104
}
105105
else
106106
{
107-
var uri = Request.RequestUri;
108-
url = uri.IsWellFormedOriginalString() ? uri.PathAndQuery : uri.GetComponents(UriComponents.PathAndQuery, UriFormat.Unescaped);
107+
url = Request.RequestUri.GetOriginalPathAndQuery();
109108
}
110109

111110
// prepare the request & headers

src/Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,9 @@ private async Task<TcpServerConnection> createServerConnection(string remoteHost
327327
{
328328
throw new Exception($"Could not establish connection to {hostname}", e);
329329
}
330+
331+
// dispose the current TcpClient and try the next address
332+
tcpClient?.Dispose();
330333
}
331334
}
332335

0 commit comments

Comments
 (0)