fastify-early-hints
fastify-early-hints copied to clipboard
http2 vs http1 support seems backwards
Prerequisites
- [X] I have written a descriptive issue title
- [X] I have searched existing issues to ensure the issue has not already been raised
Issue
So, in everything I've read, but most importantly, the Chrome docs, Early Hints are only supported on http2 and 3. But, this plugin throws an error if I try to set Fastify to use http2.
Is this not backwards? If correct as is, what's the reason we've disabled this on http/2? Thanks all!
Is this not backwards?
It is the choice from Chromium
and it does not means Early Hints
is not supported in HTTP/1.1
.
What's the reason we've disabled this on http/2?
I believe is the complexity of directly write to socket
for HTTP/2
.
Also we expect that fastify is behind a reverse proxy like Ingress/traefik which resolves a http2 request to http1.1 and vice versa.
Maybe we can transplant http2 from nodejs sourcecode to our plugin?
Maybe we can transplant http2 from nodejs sourcecode to our plugin?
Yes, we can use reply.raw.stream
for the reply.
Details on https://nodejs.org/api/http2.html#http2streamadditionalheadersheaders
I think we should just use the native functionality: https://nodejs.org/api/http2.html#responsewriteearlyhintslinks.
I think we should just use the native functionality: https://nodejs.org/api/http2.html#responsewriteearlyhintslinks.
We need to provide a compatible layer for node@14
and node@16
.
Patching to use additionalHeaders
and .socket
are needed.
And, if the native one is available, for example [email protected]
. We should absolutely go into that.
Also we expect that fastify is behind a reverse proxy like Ingress/traefik which resolves a http2 request to http1.1 and vice versa.
That's not necessarily true. A reverse proxy can still use http/2 to communicate to the backend services.
Maybe we can transplant http2 from nodejs sourcecode to our plugin?
That would be a maintenance nightmare.
That would be a maintenance nightmare.
Not really re-invented the wheel, http2
already provide a method called additionalHeaders. We can directly pass the header with additional :status
.
My assessment:
- modify formatEntry to not add "Link:" when http2
- concat the early hints into message not with CRLF but with a comma, no trailing comma
- use
additionalHeaders
instead ofwrite
on reply.raw
I am wondering how we can test http2 because undici does not support http2
I am wondering how we can test http2 because undici does not support http2
Use built-in net
or http2
package.
created #8 for discussing http2 implementation
Looks like the PR was closed without resolution :-(
Looks like the PR was closed without resolution :-(
Since, Node.js
already implemented the writeEarlyHints
in both http
and http2
.
You should use the native function instead of relying this project (unless you are in old Node.js version).
ah, would be useful to document this somewhere.
https://github.com/fastify/fastify/issues/5479