Respond with the correct error code and headers

This commit is contained in:
Misha Wolfson 2016-12-14 18:04:28 -05:00
parent 0d5021eebc
commit 512106f0a4
2 changed files with 13 additions and 11 deletions

View file

@ -24,7 +24,7 @@ if (config.get('bunyan') || config.get(env + ':use_bunyan')) {
output = bunyan.createLogger(settings); output = bunyan.createLogger(settings);
} else { } else {
output = console; output = console;
console.debug = console.log.bind(console); output.debug = console.log.bind(console);
} }
module.exports = output; module.exports = output;

View file

@ -36,16 +36,18 @@ var spserver = function(settings) {
res.addListener('finish', done); res.addListener('finish', done);
res.addListener('close', done); res.addListener('close', done);
//return base(req, res);
req.addListener('end', function () { req.addListener('end', function () {
fileServer.serve(req, res, function(e) { fileServer.serve(req, res, function (err) {
if (!e) return; if (err) {
if (e && e.status === 404 && base) { if (err.status === 404 && base) {
return base(req, res); return base(req, res);
} } else {
logger.error(e); logger.error(err);
res.writeHead(404);
res.writeHead(err.status, err.headers);
res.end(); res.end();
}
}
}); });
}).resume(); }).resume();
}); });