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

Check if header has already been set #49

Merged
merged 8 commits into from
May 18, 2021

Conversation

9662
Copy link
Contributor

@9662 9662 commented Jun 4, 2018

Fixes #48.

@coveralls
Copy link

Coverage Status

Coverage decreased (-72.6%) to 21.918% when pulling bd4108e on 9662:48-prevent-content-type-overwrite into 92338ec on hexojs:master.

@coveralls
Copy link

coveralls commented Jun 4, 2018

Coverage Status

Coverage increased (+0.06%) to 91.971% when pulling 1a08713 on 9662:48-prevent-content-type-overwrite into c3294cf on hexojs:master.

JLHwung
JLHwung previously requested changes Jun 4, 2018
@@ -30,7 +30,10 @@ module.exports = function(app) {
return;
}

res.setHeader('Content-Type', extname ? mime.lookup(extname) : 'application/octet-stream');
// Do not overwrite header if already set by another middleware
if (!res.getHeader('Content-Type')) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use hasHeader to detect whether a header has been set and add test for the new behaviors. Otherwise it looks good to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, though hasHeader will not work with Node < 7.7.0

@9662 9662 force-pushed the 48-prevent-content-type-overwrite branch from c800616 to 952becc Compare October 6, 2018 14:43
@stevenjoezhang stevenjoezhang merged commit 6048415 into hexojs:master May 18, 2021
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.

Server should check whether header has already been set to prevent overwriting
4 participants