Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The url getter of Request class does not work if there's no "host" header #571

Open
magurotuna opened this issue Dec 8, 2022 · 3 comments
Labels
need info Further information requested

Comments

@magurotuna
Copy link

The following code block depends on the presence of the "host" header.

oak/request.ts

Lines 115 to 124 in 6ffec42

if (this.#proxy) {
proto = serverRequest
.headers.get("x-forwarded-proto")?.split(/\s*,\s*/, 1)[0] ??
"http";
host = serverRequest.headers.get("x-forwarded-host") ??
serverRequest.headers.get("host") ?? "";
} else {
proto = this.#secure ? "https" : "http";
host = serverRequest.headers.get("host") ?? "";
}

However, according to RFC 9110 7.2. Host and :authority, we are allowed to NOT send the host header in HTTP/2 or HTTP/3 requests. Therefore I think it would be great to not rely on the host header.

@kitsonk
Copy link
Collaborator

kitsonk commented Mar 3, 2023

Then how would you suggest the host is determined?

@kitsonk kitsonk added the need info Further information requested label Apr 25, 2023
@martin-braun
Copy link

martin-braun commented May 19, 2024

@kitsonk :authority is a drop in replacement for Host. I try to read the Host in a proxy that I am building right now and it seems I'm unable to do so. Despite alpnProtocols: ["h2", "http/1.1"] by default, context.request.headers does not contain :authority and modern browsers don't send the Host header anymore. context.request.headers.get(":authority") is undefined, but I can confirm it being set in the browser via DevTools.

@kitsonk
Copy link
Collaborator

kitsonk commented May 20, 2024

@martin-braun moved your concern to issue #657 as it really is a different thing than this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need info Further information requested
Projects
None yet
Development

No branches or pull requests

3 participants