http2: content-encoding is incorrectly listed in kSingleValueHeaders
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 74/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- javascript, node.js
- Domain
- backend, networking
Research direction
Read lib/internal/http2/util.js, focusing on kSingleValueHeaders and the mapToHeaders and buildNgHeaderString paths. Check how duplicate content-encoding values are handled in each direction; done means incoming values are combined in order and outgoing multiple values no longer trigger ERR_HTTP2_HEADER_SINGLE_VALUE.
Written by the indexing model from the issue text.
Description
Version
v26.13.0
Platform
Subsystem
No response
What steps will reproduce the bug?
Drafted by Gemini 4 Argon.
In lib/internal/http2/util.js, HTTP2_HEADER_CONTENT_ENCODING is listed in kSingleValueHeaders:
- Incoming (
mapToHeaders): When an HTTP/2 peer sends multiplecontent-encodingheader lines (e.g.,content-encoding: gziptwice on Google Drive viewer endpoints), only the first value is kept inheaders['content-encoding']and subsequent values are silently dropped (even withstrictSingleValueFields: falsefrom #59917). As a result, HTTP/2 clients only decompress the first layer and treat the still-compressed payload as decoded data, and reverse proxies forwardingheadersstrip the remaining encoding layers so downstream browsers fail to decode the response. - Outgoing (
buildNgHeaderString): Passing multiplecontent-encodingvalues throwsERR_HTTP2_HEADER_SINGLE_VALUEby default, preventing servers and proxies from sending or forwarding multi-valuecontent-encodingheaders.
Evidence
-
HTTP Semantics — RFC 9110 §8.4 (
Content-Encoding) & §5.3:Content-Encoding = #content-codingIf one or more encodings have been applied to a representation, the sender that applied the encodings MUST generate a Content-Encoding header field that lists the content codings in the order in which they were applied.
Because
Content-Encodinguses the#elementlist ABNF production, multiplecontent-encodingheader field lines are valid per RFC 9110 §5.3 and must be combined in order with', 'rather than discarded. -
HTTP/2 & HPACK — RFC 9113 §8.2.1 & RFC 7541:
HTTP/2 only forbids connection-specific headers (connection,transfer-encoding,keep-alive,upgrade,proxy-connection); for all other fields, RFC 9113 §8.2.1 inherits RFC 9110 §5.3, allowing list-based headers to be transmitted as multiple separate HPACK header field entries (each referencing HPACK static table index 26content-encoding).nghttp2itself accepts multiplecontent-encodingentries and delivers all of them inrawHeaders—the truncation happens purely in Node's JSkSingleValueHeaderscheck. -
node:httpconsistency:lib/_http_incoming.js(_addHeaderLine) does not treatcontent-encodingas single-value and joins duplicate lines with', '.
Removing HTTP2_HEADER_CONTENT_ENCODING from kSingleValueHeaders fixes both directions.
Compatibility
- No type change:
headers['content-encoding']remainsstring | undefined(mapToHeadersjoins non-single-value headers with', '), and singlecontent-encodingresponses are unaffected. - Incoming duplicate headers:
headers['content-encoding']becomes'gzip, br'instead of'gzip'(matching what a singlecontent-encoding: gzip, brheader ornode:httpalready produces). Callers doing exact single-token checks (headers['content-encoding'] === 'gzip') without splitting on','may stop matching when a peer sends multiple lines. - Outgoing validation: Passing multiple
content-encodingvalues will succeed instead of throwingERR_HTTP2_HEADER_SINGLE_VALUE(potentiallysemver-majorper Node's error-removal policy).
How often does it reproduce? Is there a required condition?
What is the expected behavior? Why is that the expected behavior?
What do you see instead?
Additional information
No response
- Dominant language
- JavaScript
- Stars
- 123k
- Forks
- 39.3k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 238
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from nodejs/node
-
util: parseArgs() treats a `-` inside a short option group as the `--` terminatorPossibly taken @yohannesjoya claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
util.parseEnv and --env-file keep a leading UTF-8 BOM in the first keyPossibly taken @helmipradita claimed this 4 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
node:internal/inspector/network_http: `TypeError: Missing dataLength` in event when response uses `setEncoding()`May be free again A pull request for this issue was closed without being merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
nodejs/node#66551 · 1 comment ·
Maintainers usually reply within 1 day
-
[Docs] `process.loadEnvFile()` does not document behaviour when variables already existPossibly taken @Sepandard claimed this 38 days ago. Opendoc
Difficulty 1/5 Under an hour Newbie friendliness 90/100
Maintainers usually reply within 1 day
-
Stream.prototype.forEach will block in first promise in queue before read more chunkPossibly taken @mmustafasenoglu claimed this 39 days ago. Opendoc
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
riverqueue/river#1576 ·
Maintainers usually reply within 1 day
-
documentation good first issue
Difficulty 1/5 Under an hour Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
good first issue help wanted
Difficulty 1/5 Under an hour Newbie friendliness 88/100
modrollstudio/Modroll-Studio-Website#80 · 1 comment ·
Maintainers usually reply within 1 day
-
good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
mafzalkalwardev/mailforge#21 ·
-
good first issue help wanted
Difficulty 1/5 Under an hour Newbie friendliness 82/100