-
Notifications
You must be signed in to change notification settings - Fork 646
Url encoding of original query string #596
Description
Hi.
The proxy seems to be URL encoding the original query string the client sent before it passes it to the server, rather than sending the query string identical to how it was received.
I have a what I think is a "badly behaving" web site running on an embedded webserver on a network device that uses a web interface for configuration. The query string includes the characters { and } which would normally be Url encoded. When the device receives the Url encoded version of the query string, it's response is invalid, and the web interface is broken.
I have tested with some other proxy servers, and they work ok. I used Wireshark to see that the query string was being Url encoded by the Titanium-Web-Proxy.
Looking through the code, I found if I changed line 101 in Http/HttpWebClient.cs from this...
await writer.WriteLineAsync(Request.CreateRequestLine(Request.Method,
useUpstreamProxy || isTransparent ? Request.RequestUriString : Request.RequestUri.PathAndQuery,
Request.HttpVersion), cancellationToken);
to this...
await writer.WriteLineAsync(Request.CreateRequestLine(Request.Method,
useUpstreamProxy || isTransparent ? Request.RequestUriString : Request.RequestUri.GetComponents(UriComponents.PathAndQuery, UriFormat.Unescaped),
Request.HttpVersion), cancellationToken);
Then the problem goes away. It looks like Request.RequestUri.PathAndQuery is performing Url encoding.
I don't know if this is the only place this needs to be considered in the code. I have no control over the "badly behaving" devices issues, assuming it is wrong what it is doing....
Regards
Garry