Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

res.sendFile: inherit etag setting from app #2936

Closed
wants to merge 10 commits into from
Closed

res.sendFile: inherit etag setting from app #2936

wants to merge 10 commits into from

Conversation

hrvolapeter
Copy link

feature mentioned in: #2294

If ETag is disabled in app settings, res.sendFile inherits this setting in options object

lib/response.js Outdated
@@ -368,6 +371,10 @@ res.sendFile = function sendFile(path, options, callback) {
done = options;
opts = {};
}

if (app.settings.etag == false) {
opts.etag = app.settings.etag;
Copy link
Contributor

Choose a reason for hiding this comment

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

I would expect that if the user explicitly set the etag option to res.sendFile, it would not be overwritten by the setting.

@dougwilson dougwilson added this to the 5.0 milestone Mar 15, 2016
@hrvolapeter
Copy link
Author

@dougwilson I wrote those test and some of they are failing but I think it never worked, as the external package used for sending files allow only setting etag to true | false. I will take a closer look at the problem.

@dougwilson
Copy link
Contributor

The way those packages are, you cannot make them send strong ETags, because they have no way to make the guarantees required for an ETag to be strong. I'm not saying those options need to be supported, only that the behavior needs to be tested.

lib/response.js Outdated
@@ -368,6 +369,10 @@ res.sendFile = function sendFile(path, options, callback) {
done = options;
opts = {};
}

if(! ('etag' in opts) ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Pleas do not use in for option detection. This makes the interface really confusing because you have to ensure that whatever you are passing in does not have that key anywhere in the prototype chain.

lib/response.js Outdated
@@ -368,6 +369,10 @@ res.sendFile = function sendFile(path, options, callback) {
done = options;
opts = {};
}

if(typeof opts.etag == 'undefined') {
opts.etag = app.set('etag');
Copy link
Contributor

Choose a reason for hiding this comment

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

Do not pass in non-booleans to the sub module, because that is just asking for undefined behavior later. The etag option only accepts true or false.

@tunniclm
Copy link
Contributor

This PR has been updated. Github doesn't send notifications out automatically for this type of change, so this is just a comment to generate a notification.

@Doc999tor
Copy link

Any updates with this PR?
It's still relevant

@hrvolapeter
Copy link
Author

Most likely outdated

@hrvolapeter hrvolapeter closed this Dec 5, 2019
@Doc999tor
Copy link

I'm not seeing this merged
My app settings has disable: etag but sendFile doesn't obey to this setting and sets etag

@hrvolapeter
Copy link
Author

@Doc999tor You're right, this was never merged. I haven't been following development of expressjs for a few years. If you want you can finish this PR. Maybe first check if the project is still being maintained.

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