Skip to content

fix(res.send): preserve ETag generation with Transfer-Encoding - #7459

Merged
UlisesGascon merged 1 commit into
expressjs:masterfrom
cuishuang:master
Sep 15, 2026
Merged

UlisesGascon merged 1 commit into
expressjs:masterfrom
cuishuang:master

Conversation

@cuishuang

Copy link
Copy Markdown
Contributor

Preserve automatic ETag generation when res.send() is used with a pre-existing Transfer-Encoding header.

Commit 18e5985b correctly prevented Content-Length from being added when Transfer-Encoding is present, but it also moved the body-length calculation inside the same condition.

Because automatic ETag generation depends on the calculated body length, responses using Transfer-Encoding stopped receiving an ETag.

@krzysdz krzysdz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change the things mentioned in comments.

By the way, using res.send() with Transfer-Encoding may be tricky. Node.js can transfer chunked data, but different values, such as gzip, will result in an invalid response. #4893 (review)

Comment thread .DS_Store Outdated
Comment thread lib/response.js Outdated
@krzysdz krzysdz added the 5.x label Sep 7, 2026
Signed-off-by: cuishuang <imcusg@gmail.com>
@UlisesGascon UlisesGascon self-assigned this Sep 15, 2026
@UlisesGascon
UlisesGascon merged commit 9a34acf into expressjs:master Sep 15, 2026
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants