Permalink
Browse files

Merge pull request #101 from Obvious/jeremy-headMethod

Not sending bodies w/ HEAD requests in res.send()
  • Loading branch information...
2 parents 02956cc + 47c7ddd commit 3332241e60566a9dace0f86a80e5522978cf782f @azulus azulus committed Aug 23, 2012
Showing with 2 additions and 2 deletions.
  1. +2 −2 src/matador.js
View
@@ -282,7 +282,7 @@ module.exports.createApp = function (baseDir, configuration, options) {
if (data instanceof Buffer) bytesWritten = data.length
if (!res.getHeader('content-length') && typeof bytesWritten !== 'undefined') res.setHeader('content-length', bytesWritten)
- res.write(data)
+ if (req.method !== 'HEAD') res.write(data)
// done
res.end()
@@ -336,7 +336,7 @@ module.exports.createApp = function (baseDir, configuration, options) {
*/
app.preRouter = function preRouter() {
return function preRouter (req, res, next) {
- var matcher = app._pathMatchers[req.method]
+ var matcher = app._pathMatchers[req.method === 'HEAD' ? 'GET' : req.method]
// check for any handler for the http method first
if (!matcher) return next()

0 comments on commit 3332241

Please sign in to comment.