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

Commit 3940b26

Browse files
committed
do not unescape non well formatted original uris
1 parent 9fa725d commit 3940b26

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,19 @@ internal async Task SendRequest(bool enable100ContinueBehaviour, bool isTranspar
9797

9898
var writer = Connection.StreamWriter;
9999

100+
string url;
101+
if (useUpstreamProxy || isTransparent)
102+
{
103+
url = Request.RequestUriString;
104+
}
105+
else
106+
{
107+
var uri = Request.RequestUri;
108+
url = uri.IsWellFormedOriginalString() ? uri.PathAndQuery : uri.GetComponents(UriComponents.PathAndQuery, UriFormat.Unescaped);
109+
}
110+
100111
// prepare the request & headers
101-
await writer.WriteLineAsync(Request.CreateRequestLine(Request.Method,
102-
useUpstreamProxy || isTransparent ? Request.RequestUriString : Request.RequestUri.PathAndQuery,
103-
Request.HttpVersion), cancellationToken);
112+
await writer.WriteLineAsync(Request.CreateRequestLine(Request.Method, url, Request.HttpVersion), cancellationToken);
104113

105114
var headerBuilder = new StringBuilder();
106115

0 commit comments

Comments
 (0)