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

Use :authority psueod-header on HTTP/2 if available #657

Open
kitsonk opened this issue May 19, 2024 · 3 comments
Open

Use :authority psueod-header on HTTP/2 if available #657

kitsonk opened this issue May 19, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@kitsonk
Copy link
Collaborator

kitsonk 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.

Originally posted by @martin-braun in #571 (comment)

@kitsonk kitsonk added the bug Something isn't working label May 19, 2024
@kitsonk
Copy link
Collaborator Author

kitsonk commented May 19, 2024

I looked into this, Host will likely still be set when the connection is HTTP/1 to the server. If the connection is HTTP/2 then the :authority pseudo-header will be set from a browser. oak should look for the pseudo-header. This is distinct from #571 so I have split it out.

The additional problem though is that either Deno does not process the header. context.request.headers simply takes what Deno offers to it, nothing more nothing less. I am not sure if you are talking about Deno runtime or Deno Deploy (or some other runtime) but the header being missing should addressed with the runtime engine.

@martin-braun
Copy link

martin-braun commented May 20, 2024

@kitsonk Thanks for the clarification and the split, nothing to be concerned about. So you say Deno itself doesn't provide the headers? Could you please link me to the relevant code that "simply takes what Deno offers to it"? I would be happy to bubble the issue up, but I couldn't pin-point the exact code where Oak receives the headers from Deno.

And yes, you are correct about your findings, and most (if not all) common browsers switched to HTTP/2 as far as I can tell.

Thank you!

@kitsonk
Copy link
Collaborator Author

kitsonk commented May 20, 2024

The headers on the request are from the server request:

oak/request.ts

Lines 70 to 72 in 77d50d6

get headers(): Headers {
return this.#serverRequest.headers;
}

And the server request used for Deno uses the headers from the Request object provided:

get headers(): Headers {
return this.#request.headers;
}

The indirection is there is because of the evolution of Deno HTTP since 2018 and the need to support multiple runtimes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants