-
-
Notifications
You must be signed in to change notification settings - Fork 53
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
Check if header has already been set #49
Conversation
lib/middlewares/route.js
Outdated
@@ -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')) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
c800616
to
952becc
Compare
952becc
to
38a6831
Compare
Fixes #48.