Unable to set custom host #839
Description
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!