Merge pull request #326 from dead-horse/alias-headers

alias request.headers as request.header
This commit is contained in:
TJ Holowaychuk 2014-08-06 09:08:15 -07:00
commit 2d197a79fd
4 changed files with 25 additions and 0 deletions

View file

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

View file

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

View file

@ -27,6 +27,17 @@ module.exports = {
return this.req.headers;
},
/**
* Return request header, alias as request.header
*
* @return {Object}
* @api public
*/
get headers() {
return this.req.headers;
},
/**
* 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);
})
})