remove req.host=, fix docs
This commit is contained in:
parent
1d9a0e1d31
commit
f76268ba58
5 changed files with 8 additions and 28 deletions
|
@ -124,7 +124,7 @@ throw err;
|
||||||
- `ctx.querystring`
|
- `ctx.querystring`
|
||||||
- `ctx.querystring=`
|
- `ctx.querystring=`
|
||||||
- `ctx.host`
|
- `ctx.host`
|
||||||
- `ctx.host=`
|
- `ctx.hostname`
|
||||||
- `ctx.fresh`
|
- `ctx.fresh`
|
||||||
- `ctx.stale`
|
- `ctx.stale`
|
||||||
- `ctx.socket`
|
- `ctx.socket`
|
||||||
|
|
|
@ -57,12 +57,12 @@
|
||||||
|
|
||||||
### req.host
|
### 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.
|
when `app.proxy` is __true__, otherwise `Host` is used.
|
||||||
|
|
||||||
### req.host=
|
### req.hostname
|
||||||
|
Get hostname when present. Supports `X-Forwarded-Host`
|
||||||
Set the `Host` header field to a new value.
|
when `app.proxy` is __true__, otherwise `Host` is used.
|
||||||
|
|
||||||
### req.type
|
### req.type
|
||||||
|
|
||||||
|
|
|
@ -162,10 +162,10 @@ delegate(proto, 'request')
|
||||||
.access('method')
|
.access('method')
|
||||||
.access('query')
|
.access('query')
|
||||||
.access('path')
|
.access('path')
|
||||||
.access('host')
|
|
||||||
.access('url')
|
.access('url')
|
||||||
.getter('subdomains')
|
.getter('subdomains')
|
||||||
.getter('protocol')
|
.getter('protocol')
|
||||||
|
.getter('host')
|
||||||
.getter('hostname')
|
.getter('hostname')
|
||||||
.getter('header')
|
.getter('header')
|
||||||
.getter('secure')
|
.getter('secure')
|
||||||
|
|
|
@ -188,17 +188,6 @@ module.exports = {
|
||||||
return host.split(/\s*,\s*/)[0];
|
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
|
* Parse the "Host" header field hostname
|
||||||
* and support X-Forwarded-Host when a
|
* and support X-Forwarded-Host when a
|
||||||
|
|
|
@ -14,7 +14,7 @@ describe('req.host', function(){
|
||||||
var req = request();
|
var req = request();
|
||||||
req.header['x-forwarded-host'] = 'bar.com';
|
req.header['x-forwarded-host'] = 'bar.com';
|
||||||
req.header['host'] = 'foo.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.app.proxy = true;
|
||||||
req.header['x-forwarded-host'] = 'bar.com, baz.com';
|
req.header['x-forwarded-host'] = 'bar.com, baz.com';
|
||||||
req.header['host'] = 'foo.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