diff --git a/lib/router/index.js b/lib/router/index.js index 5c127eab25..df6e7e21c9 100644 --- a/lib/router/index.js +++ b/lib/router/index.js @@ -331,7 +331,7 @@ Router.prototype._optionsFor = function(path){ * @api private */ -Router.prototype._match = function(req, i){ +Router.prototype._match = function(req, i, head){ var method = req.method.toLowerCase() , url = parse(req.url) , path = url.pathname @@ -340,8 +340,17 @@ Router.prototype._match = function(req, i){ , route , keys; - // pass HEAD to GET routes - if ('head' == method) method = 'get'; + // HEAD support + // TODO: clean this up + if (!head && 'head' == method) { + // attempt lookup + route = this._match(req, i, true); + if (route) return route; + + // default to GET as res.render() / res.send() + // etc support HEAD + method = 'get'; + } // routes for this method if (routes = routes[method]) { diff --git a/test/app.head.js b/test/app.head.js index d3fa7bb345..a37c47bfde 100644 --- a/test/app.head.js +++ b/test/app.head.js @@ -24,7 +24,8 @@ describe('app.head()', function(){ , called; app.head('/tobi', function(req, res){ - res.end(); + called = true; + res.end(''); }); app.get('/tobi', function(req, res){