alias request.headers as request.header

This commit is contained in:
dead_horse 2014-08-04 11:26:07 +08:00
parent 19a9ef76e5
commit 5ca9f451a7
4 changed files with 25 additions and 0 deletions

View file

@ -10,6 +10,10 @@
Request header object. Request header object.
### req.headers
Request header object. Alias as `req.header`.
### req.method ### req.method
Request method. Request method.

View file

@ -169,6 +169,7 @@ delegate(proto, 'request')
.getter('host') .getter('host')
.getter('hostname') .getter('hostname')
.getter('header') .getter('header')
.getter('headers')
.getter('secure') .getter('secure')
.getter('stale') .getter('stale')
.getter('fresh') .getter('fresh')

View file

@ -27,6 +27,17 @@ module.exports = {
return this.req.headers; return this.req.headers;
}, },
/**
* Return request header, alias as request.header
*
* @return {Object}
* @api public
*/
get headers() {
return this.req.headers;
},
/** /**
* Get request URL. * Get request URL.
* *

9
test/request/headers.js Normal file
View file

@ -0,0 +1,9 @@
var request = require('../context').request;
describe('req.headers', function(){
it('should return the request header object', function(){
var req = request();
req.headers.should.equal(req.req.headers);
})
})