Skip to content
Myr

add support for multiple X-Forwarded-Proto values. Closes #1646

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

authored by TJ Holowaychuk · committed by TJ Holowaychuk · parent 0431d22 · Browse files · 2 files+34 added−5 removed
This commit

State

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

Diff stats

2 files+34 added−5 removed

  • tests:+30 added−0 removed
  • other:+4 added−5 removed

2 files+34 added−5 removed

modified:lib/request.js+4 added-5 removed
343 unmodified lines
344 */345346req.__defineGetter__('protocol', function(){347 var trustProxy = this.app.get('trust proxy');348 return this.connection.encrypted349 ? 'https'350 : trustProxy351 ? (this.get('X-Forwarded-Proto') || 'http')352 : 'http';348 if (this.connection.encrypted) return 'https';349 if (!trustProxy) return 'http';350 var proto = this.get('X-Forwarded-Proto') || 'http';351 return proto.split(/\s*,\s*/)[0];352});353354/**355 * Short-hand for:
171 unmodified lines
modified:test/req.secure.js+30 added