alias request.headers as request.header
This commit is contained in:
parent
19a9ef76e5
commit
5ca9f451a7
4 changed files with 25 additions and 0 deletions
|
@ -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.
|
||||||
|
|
|
@ -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')
|
||||||
|
|
|
@ -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
9
test/request/headers.js
Normal 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);
|
||||||
|
})
|
||||||
|
})
|
Loading…
Reference in a new issue