Repository navigation
Conversation
Contributor
|
Duplicate of #7467 |
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.
res.sendFile()(andres.download(), which delegates to it) overwrites the per-responseetagoption with the application setting:As a result,
{ etag: false }is ignored when the app has ETags enabled, and{ etag: true }is ignored when the app disables ETags. Express 4.21.2 passed the option through tosend, and the 5.1.0 changelog lists "Add support for ETag option inres.sendFile()" (#6073), so an explicit option should take precedence over the app-level default.This treats the app setting as a default:
Behavior without the option is unchanged:
res.sendFile()andres.download()still followapp.disable('etag').Before the fix, with default app settings on Node 26:
On Express 4.21.2 the same routes return: no ETag, no ETag, ETag.
Tests:
{ etag: false }; opt in with{ etag: true }whileapp.disable('etag')is set.res.download(path, { etag: false })sends no ETag.Without the fix the three new tests fail (3 failing). With it, the two affected files pass (88 passing), the full suite passes (1292 passing, 1 pending), and
npm run lintis clean.Refs #2294 (app-level ETag default for 5.x) and #6073 (the sendFile wiring).