Skip to content

Commit

Permalink
Check if header has already been set
Browse files Browse the repository at this point in the history
  • Loading branch information
9662 committed Jun 4, 2018
1 parent 92338ec commit bd4108e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/middlewares/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
res.setHeader('Content-Type', extname ? mime.lookup(extname) : 'application/octet-stream');
}

if (method === 'GET') {
data.pipe(res).on('error', next);
Expand Down

0 comments on commit bd4108e

Please sign in to comment.