Skip to content

fix(res.redirect): add Content-Length only if Transfer-Encoding is not present - #7507

Closed
kgeminicdev wants to merge 1 commit into
expressjs:masterfrom
kgeminicdev:fix-redirect-transfer-encoding
Closed

kgeminicdev wants to merge 1 commit into
expressjs:masterfrom
kgeminicdev:fix-redirect-transfer-encoding

Conversation

@kgeminicdev

Copy link
Copy Markdown

Fixes #7506

res.redirect() always set Content-Length, even when Transfer-Encoding was already set. That's the same conflict #4893 fixed for res.send(), and Node's HTTP client rejects such responses (Parse Error: Content-Length can't be present with Transfer-Encoding).

This applies the same guard as res.send(): Content-Length is only set when there is no Transfer-Encoding header. The status, Location header and body are unchanged.

Tests: added a case to test/res.redirect.js. It fails on master with the parse error above and passes with this change. The full suite passes (1262 passing) and npm run lint is clean.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

res.redirect() sets Content-Length when Transfer-Encoding is already set

1 participant