fix(ext/node): emit HPE_INVALID_TRANSFER_ENCODING for CL+chunked respo#33488
Merged
bartlomieju merged 1 commit intoApr 25, 2026
Conversation
Enables tests/node_compat/runner/suite/test/parallel/test-http-client-reject-chunked-with-content-length.js
fibibot
approved these changes
Apr 25, 2026
fibibot
left a comment
Contributor
There was a problem hiding this comment.
LGTM. The recovery path is well-targeted at the specific request-smuggling case the upstream test exercises:
- Upstream
parallel/test-http-client-reject-chunked-with-content-length.jssends a response with bothContent-Length: 1andTransfer-Encoding: chunkedand assertserr.code === 'HPE_INVALID_TRANSFER_ENCODING'pluserr.messagematching/^Parse Error/. prepareErrornow checkserr.code === "HPE_ERROR"(the generic code the Rust binding returns), runs two^…[ \t]*:regexes against the latin1-decoded header section ofrawPacket, and on a hit overwriteserr.code = "HPE_INVALID_TRANSFER_ENCODING"anderr.reason. The subsequenterr.message = "Parse Error: ${err.reason}"line satisfies the test's regex too.headerSegmentLatin1correctly bounds the CRLF/CRLF scan withi + 3 < lenso the last access (view[i+3]) readsview[len-1]. Falls back to scanning the whole packet when the terminator isn't found, which is fine because the regexes either match or don't.- The two regexes (
^content-length[ \\t]*:and^transfer-encoding[ \\t]*:[^\\r\\n]*\\bchunked\\b) usemfor multi-line matching andifor case-insensitive —\\bchunked\\bcorrectly distinguishes fromchunked-encoding-style values. Header folding (continuation lines starting with whitespace) isn't handled, but that's deprecated in HTTP/1.1 so unlikely to matter. - New primordials (
StringFromCharCode,TypedArrayPrototypeGet{Buffer,ByteLength,ByteOffset}) are imported correctly.for (let i = 0; i < end; i++) out += StringFromCharCode(view[i])is O(n²) on string concat but the header section is small (< a few KB) and this only runs on parse errors.
CI is 0 failures, 18 pending.
bartlomieju
approved these changes
Apr 25, 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.
Summary
Enables
test-http-client-reject-chunked-with-content-lengthin node_compat suite.Test plan
cargo test --test node_compat -- test-http-client-reject-chunked-with-content-length