commit
2de4a5561a
3 changed files with 27 additions and 1 deletions
|
@ -60,6 +60,12 @@
|
|||
Get host void of port number when present. Supports `X-Forwarded-Host`
|
||||
when `app.proxy` is __true__, otherwise `Host` is used.
|
||||
|
||||
### req.host=
|
||||
|
||||
Set host to a new value. It sets the `Host` header under the hood and will
|
||||
behave correctly with req.subdomains.
|
||||
This can be useful for a `hostOverride()` middleware
|
||||
|
||||
### req.type
|
||||
|
||||
Get request `Content-Type` void of parameters such as "charset".
|
||||
|
|
|
@ -189,6 +189,17 @@ module.exports = {
|
|||
return host.split(/\s*,\s*/)[0].split(':')[0];
|
||||
},
|
||||
|
||||
/**
|
||||
* Set the host.
|
||||
*
|
||||
* @param {String} str
|
||||
* @api public
|
||||
*/
|
||||
|
||||
set host(val) {
|
||||
this.req.headers.host = val;
|
||||
},
|
||||
|
||||
/**
|
||||
* Check if the request is fresh, aka
|
||||
* Last-Modified and/or the ETag
|
||||
|
|
|
@ -28,4 +28,13 @@ describe('req.host', function(){
|
|||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('req.host=', function(){
|
||||
it('should replace the host', function(){
|
||||
var req = request();
|
||||
req.header['host'] = 'foo.com';
|
||||
req.host = 'bar.com';
|
||||
req.host.should.equal('bar.com')
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue