Added optional app.head() support
Esse commit está contido em:
+12
-3
@@ -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
@@ -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){
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário