Skip to content
Myr

Merge tag '3.20.1'

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Douglas Christopher Wilson · committed by Douglas Christopher Wilson · parents 51f960f, b2311c7 · Browse files · 7 files+67 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

7 files+67 added−3 removed

  • tests:+52 added−0 removed
  • other:+15 added−3 removed

7 files+67 added−3 removed

modified:lib/request.js+2 added-2 removed
266 unmodified lines
267 ? 'https'268 : 'http';269 var trust = this.app.get('trust proxy fn');270271 if (!trust(this.connection.remoteAddress)) {271 if (!trust(this.connection.remoteAddress, 0)) {272 return proto;273 }274275 // Note: X-Forwarded-Proto is normally only ever a
101 unmodified lines
377defineGetter(req, 'hostname', function hostname(){378 var trust = this.app.get('trust proxy fn');379 var host = this.get('X-Forwarded-Host');380381 if (!host || !trust(this.connection.remoteAddress)) {381 if (!host || !trust(this.connection.remoteAddress, 0)) {382 host = this.get('Host');383 }384385 if (!host) return;
82 unmodified lines
modified:test/req.host.js+18 added
modified:test/req.protocol.js+17 added
73 unmodified lines
74 request(app)75 .get('/')76 .expect('http', done);77 })7879 describe('when trusting hop count', function () {80 it('should respect X-Forwarded-Proto', function (done) {81 var app = express();8283 app.set('trust proxy', 1);8485 app.use(function (req, res) {86 res.end(req.protocol);87 });8889 request(app)90 .get('/')91 .set('X-Forwarded-Proto', 'https')92 .expect('https', done);93 })94 })95 })9697 describe('when "trust proxy" is disabled', function(){98 it('should ignore X-Forwarded-Proto', function(done){
14 unmodified lines
modified:test/req.secure.js+17 added
76 unmodified lines
77 .get('/')78 .set('X-Forwarded-Proto', 'https, http')79 .expect('yes', done)80 })8182 describe('when "trust proxy" trusting hop count', function () {83 it('should respect X-Forwarded-Proto', function (done) {84 var app = express();8586 app.set('trust proxy', 1);8788 app.get('/', function (req, res) {89 res.send(req.secure ? 'yes' : 'no');90 });9192 request(app)93 .get('/')94 .set('X-Forwarded-Proto', 'https')95 .expect('yes', done)96 })97 })98 })99 })100})
modified:.travis.yml+1 added
modified:History.md+12 added
1unreleased2==========34 * Fix `req.host` when using "trust proxy" hops count5 * Fix `req.protocol`/`req.secure` when using "trust proxy" hops count674.12.0 / 2015-02-238===================910 * Fix `"trust proxy"` setting to inherit when app is mounted
696 unmodified lines
707 - `app.router()` - returns the app Router instance708 - `app.route()` - Proxy to the app's `Router#route()` method to create a new route709 - Router & Route - public API7107113.20.1 / 2015-02-28712===================713714 * Fix `req.host` when using "trust proxy" hops count715 * Fix `req.protocol`/`req.secure` when using "trust proxy" hops count7167173.20.0 / 2015-02-18718===================719720 * Fix `"trust proxy"` setting to inherit when app is mounted
1988 unmodified lines
modified:package.json-1 removed
58 unmodified lines
59 "marked": "0.3.3",60 "mocha": "~2.1.0",61 "should": "~5.0.1",62 "supertest": "~0.15.0",63 "hjs": "~0.0.6",63 "body-parser": "~1.12.0",64 "connect-redis": "~2.2.0",65 "cookie-parser": "~1.3.4",66 "express-session": "~1.10.3",
23 unmodified lines