Repository navigation
fix(res.redirect): avoid Content-Length with Transfer-Encoding - #7508
Open
0d00ciallo0721 wants to merge 1 commit into
Open
0d00ciallo0721 wants to merge 1 commit into
0d00ciallo0721 wants to merge 1 commit into
Conversation
0d00ciallo0721
marked this pull request as ready for review
October 6, 2026 08:40
0d00ciallo0721
force-pushed
the
agent-tasks/7506
branch
from
October 6, 2026 16:23
34ece15 to
e8addac
Compare
kgeminicdev
reviewed
Oct 6, 2026
kgeminicdev
left a comment
There was a problem hiding this comment.
As the reporter of #7506, I can confirm this fixes it. I checked out the branch: test/res.redirect.js passes (14) and the full suite passes (1262). I also tried a case the new test doesn't cover: a HEAD request with Transfer-Encoding: chunked set before res.redirect(301, ...) returns 301 with no Content-Length, Transfer-Encoding intact and Location preserved.
One optional nit: res.send() has a short comment explaining why Content-Length is skipped when Transfer-Encoding is set. The same one-liner here would keep the two in sync for the next reader.
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.
Fixes #7506
res.redirect()currently addsContent-Lengtheven when an application has already setTransfer-Encoding. That produces a response Node's HTTP parser rejects. This change follows the existingres.send()behavior and only sets the length when noTransfer-Encodingheader is present.AI assistance was used to prepare the implementation and regression test.
Verification
masterwithHPE_INVALID_CONTENT_LENGTHand passes with this change.npm test— 1262 passing.npm run lint— passed.