http2: content-encoding is incorrectly listed in kSingleValueHeaders
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 74/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- javascript, node.js
- Lĩnh vực
- backend, networking
Hướng nghiên cứu
Đọc lib/internal/http2/util.js, tập trung vào kSingleValueHeaders và các đường xử lý mapToHeaders và buildNgHeaderString. Kiểm tra cách các giá trị content-encoding trùng lặp được xử lý theo từng hướng; công việc hoàn tất khi các giá trị đầu vào được kết hợp theo thứ tự và nhiều giá trị đầu ra không còn gây ra ERR_HTTP2_HEADER_SINGLE_VALUE.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- JavaScript
- Star
- 123k
- Fork
- 39.3k
- Merge trung bình
- 4 ngày 15 giờ
- Pull request đã merge (30 ngày)
- 238
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của nodejs/node
-
util.parseEnv and --env-file keep a leading UTF-8 BOM in the first keyCó thể đã có người làm @helmipradita đã nhận 4 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
node:internal/inspector/network_http: `TypeError: Missing dataLength` in event when response uses `setEncoding()`Có thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
nodejs/node#66551 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Docs] `process.loadEnvFile()` does not document behaviour when variables already existCó thể đã có người làm @Sepandard đã nhận 38 ngày trước. Đang mởdoc
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Stream.prototype.forEach will block in first promise in queue before read more chunkCó thể đã có người làm @mmustafasenoglu đã nhận 39 ngày trước. Đang mởdoc
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 1 ngày
-
nodejs 26.8.2 fails to build with clang/LLVMCó thể làm lại được @btyagi18 đã nhận 25 ngày trước và không có pull request nào đang mở. Đang mởbuild
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
nodejs/node#66076 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
521xueweihan/HelloGitHub#4237 ·
-
Incorrect fuctioning of `Container.removeChildren()` when provided with nonzero starting indexĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 2 ngày
-
bug confirmed js v6
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
area/frontend area/v2 kind/bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
Maintainer thường phản hồi trong vòng 1 ngày