fix: strip headers listed in Connection header per RFC 7230 Section 6.1#450
Merged
fix: strip headers listed in Connection header per RFC 7230 Section 6.1#450
Conversation
Per RFC 7230 Section 6.1, a proxy MUST parse the Connection header and remove any headers listed within it before forwarding the request. Previously, only the Connection header itself was stripped but headers named inside it (e.g., Connection: X-Custom-Header) were forwarded. This change: - Adds getConnectionHeaders() to parse Connection header values - Updates stripHttp1ConnectionHeaders() to also strip listed headers - Updates handleHttp1Req() and handleUndici() to strip listed headers - Adds tests for the new behavior Fixes #449
jsumners
approved these changes
Jan 27, 2026
Member
jsumners
left a comment
There was a problem hiding this comment.
No blockers, only suggestions.
climba03003
approved these changes
Jan 28, 2026
Address review comments: - Remove redundant !connectionHeader check since typeof covers it - Flip condition order to check comma first (more common case)
jsumners
approved these changes
Jan 31, 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
Per RFC 7230 Section 6.1, a proxy MUST parse the Connection header and remove any headers listed within it before forwarding the request.
Previously, only the Connection header itself was stripped but headers named inside it (e.g.,
Connection: X-Custom-Header) were forwarded to upstream.Changes
getConnectionHeaders()to parse Connection header valuesstripHttp1ConnectionHeaders()to also strip listed headershandleHttp1Req()andhandleUndici()to strip listed headersExample
Request from client:
Before: Only
Connectionwas stripped;X-Custom-Headerwas forwarded to upstream.After: Both
ConnectionandX-Custom-Headerare stripped before forwarding.Test plan
Fixes #449