Added optional app.head() support

Esse commit está contido em:
Tj Holowaychuk
2011-11-11 13:53:20 -08:00
commit 2876424240
2 arquivos alterados com 14 adições e 4 exclusões
+12 -3
Ver Arquivo
@@ -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]) {
+2 -1
Ver Arquivo
@@ -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){