http2: content-encoding is incorrectly listed in kSingleValueHeaders
維護者通常 1 天內回覆
評估
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 新手友好度
- 74/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 活躍
- 技術堆疊
- javascript, node.js
- 領域
- backend, networking
研究方向
閱讀 lib/internal/http2/util.js,重點關注 kSingleValueHeaders 以及 mapToHeaders 和 buildNgHeaderString 路徑。檢查每個方向如何處理重複的 content-encoding 值;完成標準是傳入值依序合併,且多個傳出值不再觸發 ERR_HTTP2_HEADER_SINGLE_VALUE。
由索引模型根據 Issue 內容生成。
描述
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
- 主要語言
- JavaScript
- 星號
- 123k
- 分支
- 39.3k
- 平均合併
- 4 天 16 小時
- 30 天內合併 PR
- 227
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
nodejs/node 的其他 Issue
-
util.parseEnv and --env-file keep a leading UTF-8 BOM in the first key可能已有人在做 @helmipradita 於 3 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
node:internal/inspector/network_http: `TypeError: Missing dataLength` in event when response uses `setEncoding()`可能重新可做 關聯的 PR 已關閉且未合併。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
[Docs] `process.loadEnvFile()` does not document behaviour when variables already exist可能已有人在做 @Sepandard 於 37 天前認領。 未關閉doc
難度 1/5 1 小時以內 新手友好度 90/100
維護者通常 1 天內回覆
-
Stream.prototype.forEach will block in first promise in queue before read more chunk可能已有人在做 @mmustafasenoglu 於 38 天前認領。 未關閉doc
難度 2/5 1-3 小時 新手友好度 65/100
維護者通常 1 天內回覆
-
nodejs 26.8.2 fails to build with clang/LLVM可能重新可做 @btyagi18 於 24 天前認領,目前沒有進行中的 PR。 未關閉build
難度 1/5 1 小時以內 新手友好度 88/100
維護者通常 1 天內回覆
相似的 Issue
-
needs-triage
難度 2/5 1-3 小時 新手友好度 66/100
microsoft/playwright#43875 · 1 則留言 ·
維護者通常 1 天內回覆
-
Run the dependency drift check可能已有人在做 @spaceninja 今天認領。 未關閉
難度 1/5 1 小時以內 新手友好度 82/100
cloudfour/stylelint-config-cloudfour#683 ·
維護者通常 1 天內回覆
-
Documentation Enhancement
難度 2/5 1-3 小時 新手友好度 72/100
JSPrismarine/JSPrismarine#2706 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 72/100
PostHog/posthog-js#5524 ·
維護者通常 2 天內回覆
-
enhancement good first issue help wanted
難度 2/5 半天 新手友好度 66/100
AlphaaCode/Popbook#10 ·