added setters for header and headers, fixes #991
This commit is contained in:
parent
f6f1ab73e1
commit
012587889d
4 changed files with 40 additions and 0 deletions
|
@ -10,10 +10,18 @@
|
|||
|
||||
Request header object.
|
||||
|
||||
### request.header=
|
||||
|
||||
Set request header object.
|
||||
|
||||
### request.headers
|
||||
|
||||
Request header object. Alias as `request.header`.
|
||||
|
||||
### request.headers=
|
||||
|
||||
Set request header object. Alias as `request.header=`.
|
||||
|
||||
### request.method
|
||||
|
||||
Request method.
|
||||
|
|
|
@ -31,6 +31,16 @@ module.exports = {
|
|||
return this.req.headers;
|
||||
},
|
||||
|
||||
/**
|
||||
* Set request header.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
set header(val) {
|
||||
this.req.headers = val;
|
||||
},
|
||||
|
||||
/**
|
||||
* Return request header, alias as request.header
|
||||
*
|
||||
|
@ -42,6 +52,16 @@ module.exports = {
|
|||
return this.req.headers;
|
||||
},
|
||||
|
||||
/**
|
||||
* Set request header, alias as request.header
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
set headers(val) {
|
||||
this.req.headers = val;
|
||||
},
|
||||
|
||||
/**
|
||||
* Get request URL.
|
||||
*
|
||||
|
|
|
@ -9,4 +9,10 @@ describe('req.header', () => {
|
|||
const req = request();
|
||||
assert.deepEqual(req.header, req.req.headers);
|
||||
});
|
||||
|
||||
it('should set the request header object', () => {
|
||||
const req = request();
|
||||
req.header = {'X-Custom-Headerfield': 'Its one header, with headerfields'};
|
||||
assert.deepEqual(req.header, req.req.headers);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -9,4 +9,10 @@ describe('req.headers', () => {
|
|||
const req = request();
|
||||
assert.deepEqual(req.headers, req.req.headers);
|
||||
});
|
||||
|
||||
it('should set the request header object', () => {
|
||||
const req = request();
|
||||
req.headers = {'X-Custom-Headerfield': 'Its one header, with headerfields'};
|
||||
assert.deepEqual(req.headers, req.req.headers);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue