Skip to content

Commit

Permalink
Fixes 404 when request header Accept-Encoding not set
Browse files Browse the repository at this point in the history
When static middleware is enabled, sending a request without
Accept-Encoding set would cause a premature call to pass()
before checking if the requested file exists. This meant that
calls to normal Express routes would be intercepted and result
in 404s.
  • Loading branch information
underbluewaters committed Dec 7, 2012
1 parent bca6fd4 commit 10d1817
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/staticGzip.js
Expand Up @@ -209,7 +209,6 @@ exports = module.exports = function staticGzip(dirPath, options){
}
}

if (!method) return pass(filename);

fs.stat(filename, function(err, stat) {

Expand All @@ -221,6 +220,9 @@ exports = module.exports = function staticGzip(dirPath, options){
return next();
}

// Check if file exists before passing uncompressed to client
if (!method) return pass(filename);

if (!contentTypeMatch.test(contentType)) {
return pass(filename);
}
Expand Down

0 comments on commit 10d1817

Please sign in to comment.