Skip to content
Myr

Added X-Forwarded-Proto support to `req.secure`

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 ba570a9 · Browse files · 1 file+5 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

1 file+5 added−3 removed

  • other:+5 added−3 removed

1 file+5 added−3 removed

modified:lib/request.js+5 added-3 removed
307 unmodified lines
308 */309310req.__defineGetter__('protocol', function(trustProxy){311 var trustProxy = this.app.settings['trust proxy'];312 return this.secure312 return this.connection.encrypted313 ? 'https'314 : trustProxy315 ? (this.get('X-Forwarded-Proto') || 'http')316 : 'http';317});318319/**320 * Short-hand for `req.connection.encrypted`.320 * Short-hand for:321 *322 * req.protocol == 'https'323 *324 * @return {Boolean}325 * @api public326 */327328req.__defineGetter__('secure', function(){327 return this.connection.encrypted;329 return 'https' == this.protocol;330});331332/**333 * Return subdomains as an array.
63 unmodified lines