Permalink
Browse files

Don't write a body for HEAD requests.

  • Loading branch information...
1 parent d7fc882 commit 84b5ad9e466b186abe1efa246fdfb6c60cc38e77 Will White committed Mar 23, 2012
Showing with 4 additions and 4 deletions.
  1. +4 −4 server/middleware.js
View
@@ -79,16 +79,16 @@ exports['showError'] = function showError() {
if ((req.headers.accept + '' || '').indexOf('json') >= 0) {
res.writeHead(err.status, { 'Content-Type': 'application/json' });
if (env === 'development') {
- res.end(JSON.stringify(err));
+ res.end('HEAD' == req.method ? null : JSON.stringify(err));
} else {
- res.end(JSON.stringify({ message: err.message }));
+ res.end('HEAD' == req.method ? null : JSON.stringify({ message: err.message }));
}
} else {
res.writeHead(err.status, { 'Content-Type': 'text/plain' });
if (env === 'development') {
- res.end(err.stack);
+ res.end('HEAD' == req.method ? null : err.stack);
} else {
- res.end(err.message);
+ res.end('HEAD' == req.method ? null : err.message);
}
}
};

0 comments on commit 84b5ad9

Please sign in to comment.