Ensure conflicting flat headers in HTTP/2 are combined correctly#4196
Merged
metcoder95 merged 2 commits intonodejs:mainfrom May 9, 2025
Merged
Ensure conflicting flat headers in HTTP/2 are combined correctly#4196metcoder95 merged 2 commits intonodejs:mainfrom
metcoder95 merged 2 commits intonodejs:mainfrom
Conversation
Undici's header handling combined array-valued header values without a
space. Node's built-in HTTP/2 header handling (used only for keys that
differ only in case) combined them with a space (", "). This makes those
match so everything has a space, which is a little more readable &
consistent.
Member
Author
|
Failing tests (inspection & sqlite-cache-store) seem unrelated to me. |
metcoder95
approved these changes
May 7, 2025
Ethan-Arrowood
approved these changes
May 8, 2025
caitp
pushed a commit
to caitp/undici
that referenced
this pull request
May 15, 2025
slagiewka
pushed a commit
to slagiewka/undici
that referenced
this pull request
Feb 14, 2026
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 relates to...
When passing a flat header array and using HTTP/2, duplicate keys were discarded and lost unexpectedly.
In addition, the value-combining formatting (effectively
join(',')) for explicitly array-valued headers in HTTP/2 didn't quite match the formatting for both Undici HTTP/1 or for Node HTTP/2's value-combining behaviour for headers that differ only by case (both of which dojoin(', ')- i.e. with whitespace) which was a bit weird.Rationale
The response shows what the server receives: headers including
a: cbut withouta: b(all but the last header value is lost).The header array-to-object logic ignored duplicate keys like this.
Regarding the formatting:
{ 'a': ['b', 'c'] }is sent asa: b, c(whitespace){ 'a': 'b', 'A': 'c' }is sent asa: b, c(whitespace){ 'a': ['b', 'c'] }was sent asa: b,c(no whitespace)(I'm not claiming this formatting is particularly important, but I would've had to reproduce the inconsistency in the tests, and it's nicer to tidy it up & make these headers a bit more readable en route).
Once nodejs/node#57917 is released (e.g. Node v24) we will be able to skip this entirely, and pass raw headers as-is directly to Node's HTTP/2 APIs, so these headers won't be combined at all - but that will have to wait until later, and will only apply for Node versions including that change anyway.
Changes
N/A
Features
N/A
Bug Fixes
Breaking Changes and Deprecations
N/A
Status