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

Url encoding of original query string #596

@gt5700

Description

@gt5700

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions