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.

Unable to set custom host #839

Open
Open
@joaope

Description

@joaope

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!

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions