Skip to content
Myr

Added `req.protocol()`

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 ff92afa · Browse files · 2 files+91 added−0 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+91 added−0 removed

  • tests:+73 added−0 removed
  • other:+18 added−0 removed

2 files+91 added−0 removed

modified:lib/request.js+18 added
309 unmodified lines
310 return !! ~ct.indexOf(type);311};312313/**314 * Return the protocol string "http" or "https",315 * while optionally trusting X-Forwarded-Proto316 * when running behind a reverse proxy.317 *318 * @param {Boolean} trustProxy319 * @return {String}320 * @api public321 */322323req.protocol = function(trustProxy){324 return this.secure325 ? 'https'326 : trustProxy327 ? (this.header('X-Forwarded-Proto') || 'http')328 : 'http';329};330331/**332 * Short-hand for `req.connection.encrypted`.333 *334 * @return {Boolean}335 * @api public
53 unmodified lines
added:test/req.protocol.js+73 added