titanium-web-proxy icon indicating copy to clipboard operation
titanium-web-proxy copied to clipboard

Unable to set custom host

Open joaope opened this issue 4 years ago • 3 comments

While rewriting a request one can't set a custom host header independent from the request url.

Meaning, either through

session.HttpClient.Request.Host = "custom.host.com" or session.HttpClient.Request.Headers.AddHeader("Host", "custom.host.com")

this won't ever send Host: custom.host.com as a header because request.Host is being overridden by Request.RequestUriString and by the RequestHandler itself.

I guess my question is, how do we do this:

GET https://absolute.resource.com/path.png HTTP/1.1
Host: custom.host.com
GET https://absolute.resource.com/path.png HTTP/1.1
Host: another.host.com

We serve different hosts on the same server and this way we can't differentiate between them. Also this is a normal scenario when the server has a proxy in front of it.

Is this intentional? I understand something different by reading the RFC:

The Host field value MUST represent the naming authority of the origin server or gateway given by the original URL. This allows the origin server or gateway to differentiate between internally-ambiguous URLs, such as the root "/" URL of a server for multiple host names on a single IP address.

I might be reading it wrong. Any guidance here? I know this worked before and now we are stuck on an old package version simply because of this.

Available to open a PR if that's the case. Thank you!

joaope avatar Mar 02 '21 01:03 joaope

Please open a PR.

honfika avatar Jan 29 '22 23:01 honfika

While rewriting a request one can't set a custom host header independent from the request url.

Meaning, either through

session.HttpClient.Request.Host = "custom.host.com" or session.HttpClient.Request.Headers.AddHeader("Host", "custom.host.com")

this won't ever send Host: custom.host.com as a header because request.Host is being overridden by Request.RequestUriString and by the RequestHandler itself.

I guess my question is, how do we do this:

GET https://absolute.resource.com/path.png HTTP/1.1
Host: custom.host.com
GET https://absolute.resource.com/path.png HTTP/1.1
Host: another.host.com

We serve different hosts on the same server and this way we can't differentiate between them. Also this is a normal scenario when the server has a proxy in front of it.

Is this intentional? I understand something different by reading the RFC:

The Host field value MUST represent the naming authority of the origin server or gateway given by the original URL. This allows the origin server or gateway to differentiate between internally-ambiguous URLs, such as the root "/" URL of a server for multiple host names on a single IP address.

I might be reading it wrong. Any guidance here? I know this worked before and now we are stuck on an old package version simply because of this.

Available to open a PR if that's the case. Thank you!

I seem to have the same problem. Can you tell me how you solve this problem?

ghost avatar May 13 '22 05:05 ghost

I seem to have the same problem. Can you tell me how you solve this problem?

I didn't. Just pinned this package's version to one that it's working (3.0.632) and currently moving on to other approaches that don't require it at all. The package is too buggy and unfortunately we don't have the time or bandwidth too work on it.

joaope avatar May 13 '22 08:05 joaope