http: add writeInformation to send arbitrary 1xx status codes#63155
Open
pimterry wants to merge 1 commit intonodejs:mainfrom
Open
http: add writeInformation to send arbitrary 1xx status codes#63155pimterry wants to merge 1 commit intonodejs:mainfrom
pimterry wants to merge 1 commit intonodejs:mainfrom
Conversation
Collaborator
|
Review requested:
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #63155 +/- ##
=======================================
Coverage 89.65% 89.65%
=======================================
Files 713 713
Lines 224134 224189 +55
Branches 42320 42337 +17
=======================================
+ Hits 200939 200999 +60
- Misses 14996 15002 +6
+ Partials 8199 8188 -11
🚀 New features to boost your workflow:
|
metcoder95
approved these changes
May 7, 2026
Member
metcoder95
left a comment
There was a problem hiding this comment.
Don't have approval power, but lgtm; nice addition
Signed-off-by: Tim Perry <pimterry@gmail.com>
d6b58d7 to
af03c6b
Compare
Member
Author
|
Rebased to hopefully fix the build now that the QUIC coverage issue is sorted. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This provides a generic HTTP/1 API for 1xx responses, equivalent to our existing HTTP/2 additionalHeaders API. This supports any 1xx status code, except 101, which I've intentionally excluded - since it changes the protocol entirely, there's no possible way to unilaterally send that without breaking things later in our current API, so you just have to use 'upgrade' in that case.
This fixes various past requests like:
And acts as a nice workaround to solve:
(All 3 closed as stale, not fixed)
I'm also hoping it'll discourage usage of the private
res._writeRawmethod as a workaround for the existing limitations. We even did this in our own tests, see test/parallel/test-http-information-headers.js here.This is useful to support custom 1xx values (perfectly valid AFAICT, if unusual), proxies (who want to pass through data in a standard way, without having to separately handle each case individually as today) and to give us trivial general support for future standardized 1xx values, without needing a whole separate PR to add a new per-status API every time.
The existing methods are refactored to use the generic method under the hood, and HTTP/2 compat uses additionalHeaders.
There's one annoying inconsistency here: the H1 methods throw if we've already sent a final status code, while the H2 methods just no-op. I've kept that as-is and matched this in the new method to avoid a breaking change, but it would probably be best to align on throwing in both cases in a separate major bump.