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

How to support HTTP 103 Early Hints? #4938

Closed
zizifn opened this issue Jun 22, 2022 · 5 comments
Closed

How to support HTTP 103 Early Hints? #4938

zizifn opened this issue Jun 22, 2022 · 5 comments
Labels

Comments

@zizifn
Copy link

zizifn commented Jun 22, 2022

hi,

WIth Chrome 103, the HTTP 103 Early Hints is in release build. But how to support this in expressjs? Thanks!!

https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/103
https://developer.chrome.com/blog/new-in-chrome-103/

@zizifn zizifn changed the title How to use HTTP 103 Early Hints How to use HTTP 103 Early Hints? Jun 22, 2022
@zizifn zizifn changed the title How to use HTTP 103 Early Hints? How to support HTTP 103 Early Hints? Jun 22, 2022
@dougwilson
Copy link
Contributor

dougwilson commented Jun 22, 2022

The Node.js server Express.js is built on does not yet support 103, only 100, 101 and 102. You'll want to petition Node.js to add 103 support to their HTTP server so it can be made available in Express.js and other frameworks built on Node.js HTTP.

@dougwilson dougwilson closed this as not planned Won't fix, can't repro, duplicate, stale Jun 22, 2022
@fishcharlie
Copy link

@dougwilson Node.js looks to have merged this nodejs/node#44180. However, I don't think it has been included in a Node.js release (yet).

What are the odds this can be revisited/reopened?

Obviously this leads to a lot more questions. What is Express.js's policy about new Node.js changes that aren't back-ported? Express.js currently supports Node.js >=0.10.0, and I'd be shocked if that PR gets back-ported that far. How many Node.js versions should this be included in before Express.js supports this feature? etc.

@dougwilson
Copy link
Contributor

Hi @fishcharlie I'm not sure what needs to be re-opened? Until that lands, it isn't possible to send the 103 response in Express.js since Node.js does not support it. Once that PR lands in Node.js, the API is automatically available in Express.js when used with that Node.js version. But Express.js cannot backport things to old Node.js versions, only the Node.js project can... Please let me know if I'm missing something.

@fishcharlie
Copy link

@dougwilson Thanks so much for the reply.

Everything (minus one part) you said makes sense and I agree with all of it.

Once that PR lands in Node.js, the API is automatically available in Express.js when used with that Node.js version

This is the part I'm slightly confused about. I was under the impression that Express.js was basically a wrapper around the Node.js HTTP package. Therefore, wouldn't the wrapper need to be updated to support that new method?

Methods such as res.set don't exist within the native HTTP package (I assume it gets mapped to response.setHeader).

So shouldn't Express.js (at some point) add a new method for the writeEarlyHints method that was added in that PR? Similar to how res.set maps to response.setHeader. Something like res.earlyHints that gets mapped to response.writeEarlyHints?

@dougwilson
Copy link
Contributor

dougwilson commented Oct 7, 2022

No, it's not a wrapper, it is inheritance. Anything on the Node.js response is on the Express.js response, because it's just class inheritance. The Express.js response is just a subclass of the Node.js response. You'll notice you can call res.writeProcessing() and res.writeContinue() in your Express.js middleware, yet you won't find those anywhere in the Express.js source code, since nothing needs to be done to add methods from the Node.js classes to the Express.js ones. I hope that helps.

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

No branches or pull requests

3 participants