commit
50ffb86a40
5 changed files with 8 additions and 28 deletions
|
@ -124,7 +124,7 @@ throw err;
|
|||
- `ctx.querystring`
|
||||
- `ctx.querystring=`
|
||||
- `ctx.host`
|
||||
- `ctx.host=`
|
||||
- `ctx.hostname`
|
||||
- `ctx.fresh`
|
||||
- `ctx.stale`
|
||||
- `ctx.socket`
|
||||
|
|
|
@ -57,12 +57,12 @@
|
|||
|
||||
### req.host
|
||||
|
||||
Get host void of port number when present. Supports `X-Forwarded-Host`
|
||||
Get host(hostname:port) when present. Supports `X-Forwarded-Host`
|
||||
when `app.proxy` is __true__, otherwise `Host` is used.
|
||||
|
||||
### req.host=
|
||||
|
||||
Set the `Host` header field to a new value.
|
||||
### req.hostname
|
||||
Get hostname when present. Supports `X-Forwarded-Host`
|
||||
when `app.proxy` is __true__, otherwise `Host` is used.
|
||||
|
||||
### req.type
|
||||
|
||||
|
|
|
@ -162,10 +162,10 @@ delegate(proto, 'request')
|
|||
.access('method')
|
||||
.access('query')
|
||||
.access('path')
|
||||
.access('host')
|
||||
.access('url')
|
||||
.getter('subdomains')
|
||||
.getter('protocol')
|
||||
.getter('host')
|
||||
.getter('hostname')
|
||||
.getter('header')
|
||||
.getter('secure')
|
||||
|
|
|
@ -188,17 +188,6 @@ module.exports = {
|
|||
return host.split(/\s*,\s*/)[0];
|
||||
},
|
||||
|
||||
/**
|
||||
* Set the host.
|
||||
*
|
||||
* @param {String} str
|
||||
* @api public
|
||||
*/
|
||||
|
||||
set host(val) {
|
||||
this.req.headers.host = val;
|
||||
},
|
||||
|
||||
/**
|
||||
* Parse the "Host" header field hostname
|
||||
* and support X-Forwarded-Host when a
|
||||
|
|
|
@ -14,7 +14,7 @@ describe('req.host', function(){
|
|||
var req = request();
|
||||
req.header['x-forwarded-host'] = 'bar.com';
|
||||
req.header['host'] = 'foo.com';
|
||||
req.host.should.equal('foo.com')
|
||||
req.host.should.equal('foo.com');
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -24,17 +24,8 @@ describe('req.host', function(){
|
|||
req.app.proxy = true;
|
||||
req.header['x-forwarded-host'] = 'bar.com, baz.com';
|
||||
req.header['host'] = 'foo.com';
|
||||
req.host.should.equal('bar.com')
|
||||
req.host.should.equal('bar.com');
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
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