Merge pull request #278 from dead-horse/host-setter

remove req.host=
This commit is contained in:
TJ Holowaychuk 2014-05-05 08:42:28 -07:00
commit 50ffb86a40
5 changed files with 8 additions and 28 deletions

View file

@ -124,7 +124,7 @@ throw err;
- `ctx.querystring`
- `ctx.querystring=`
- `ctx.host`
- `ctx.host=`
- `ctx.hostname`
- `ctx.fresh`
- `ctx.stale`
- `ctx.socket`

View file

@ -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

View file

@ -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')

View file

@ -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

View file

@ -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')
})
})