Skip to content

Commit

Permalink
Don't log an error when we get a 404 request - it's normal to get 404s.
Browse files Browse the repository at this point in the history
  • Loading branch information
mhansen committed May 21, 2010
1 parent 506b677 commit cbc6377
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions lib/antinode.js
Expand Up @@ -93,24 +93,28 @@ function try_stream(path, req, resp) {

fs.stat(path, function (err, stats) {
if (err) {
log.error("fs.stat(",path,") failed: ", err);
// ENOENT is normal on 'file not found'
if (err.errno != process.ENOENT) {
// any other error is abnormal - log it
log.error("fs.stat(",path,") failed: ", err);
}
return file_not_found();
}
if (stats.isDirectory()) {
return try_stream(pathlib.join(path, "index.html"), req, resp);
}
if (!stats.isFile()) {
file_not_found();
return file_not_found();
} else {
var if_modified_since = req.headers['if-modified-since'];
if (if_modified_since) {
var req_date = new Date(if_modified_since);
if (stats.mtime <= req_date && req_date <= Date.now()) {
not_modified();
return not_modified();
}
else stream_file(path, stats);
} else {
stream_file(path, stats);
return stream_file(path, stats);
}
}
});
Expand All @@ -119,8 +123,7 @@ function try_stream(path, req, resp) {
fs.open(file,'r', 0660, function(err, fd) {
if (err) {
log.debug("fs.open(",file,") error: ",err.message);
file_not_found();
return;
return file_not_found();
}
log.debug("opened", path, "on fd", fd);

Expand Down

0 comments on commit cbc6377

Please sign in to comment.