request.js
This file
Path
lib/request.js
507 lines · 11.2 KiB · JavaScript
Last changed by
Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e
History of this fileTake it
The walk stopped after 200 commits: lines older than a01326a point at it.
Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
lines 1–10why, one step back1/*!2 * express3 * Copyright(c) 2009-2013 TJ Holowaychuk4 * Copyright(c) 2013 Roman Shtylman5 * Copyright(c) 2014-2015 Douglas Christopher Wilson6 * MIT Licensed7 */89'use strict';10Catch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a
lines 11–12why, one step back11/**12 * Module dependencies.Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
line 13why, one step back13 * @privateCatch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a
lines 14–16why, one step back14 */1516var accepts = require('accepts');Merge tag '3.17.1'Douglas Christopher Wilsonbefore adoption3dca534
line 17why, one step back17var isIP = require('net').isIP;Catch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a
lines 18–26why, one step back18var typeis = require('type-is');19var http = require('http');20var fresh = require('fresh');21var parseRange = require('range-parser');22var parse = require('parseurl');23var proxyaddr = require('proxy-addr');2425/**26 * Request prototype.Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e
line 27why, one step back27 * @publicCatch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a
lines 28–29why, one step back28 */29Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e
line 30why, one step back30var req = Object.create(http.IncomingMessage.prototype)Catch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a
lines 31–32why, one step back3132/**Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e
lines 33–39why, one step back33 * Module exports.34 * @public35 */3637module.exports = req3839/**Catch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a
lines 40–59why, one step back40 * Return request header.41 *42 * The `Referrer` header field is special-cased,43 * both `Referrer` and `Referer` are interchangeable.44 *45 * Examples:46 *47 * req.get('Content-Type');48 * // => "text/plain"49 *50 * req.get('content-type');51 * // => "text/plain"52 *53 * req.get('Something');54 * // => undefined55 *56 * Aliased as `req.header()`.57 *58 * @param {String} name59 * @return {String}Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
line 60why, one step back60 * @publicCatch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a
lines 61–63why, one step back61 */6263req.get =Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
line 64why, one step back64req.header = function header(name) {Merge tag '4.14.0'Douglas Christopher Wilsonbefore adoption1dbfee6
lines 65–72why, one step back65 if (!name) {66 throw new TypeError('name argument is required to req.get');67 }6869 if (typeof name !== 'string') {70 throw new TypeError('name must be a string to req.get');71 }72Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
lines 73–75why, one step back73 var lc = name.toLowerCase();7475 switch (lc) {Catch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a
lines 76–80why, one step back76 case 'referer':77 case 'referrer':78 return this.headers.referrer79 || this.headers.referer;80 default:Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
line 81why, one step back81 return this.headers[lc];Catch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a
lines 82–91why, one step back82 }83};8485/**86 * To do: update docs.87 *88 * Check if the given `type(s)` is acceptable, returning89 * the best match when true, otherwise `undefined`, in which90 * case you should respond with 406 "Not Acceptable".91 *Merge tag '4.12.0'Douglas Christopher Wilsonbefore adoptionf6ec710
lines 92–94why, one step back92 * The `type` value may be a single MIME type string93 * such as "application/json", an extension name94 * such as "json", a comma-delimited list such as "json, html, text/plain",Catch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a
lines 95–96why, one step back95 * an argument list such as `"json", "html", "text/plain"`,96 * or an array `["json", "html", "text/plain"]`. When a listMerge tag '4.12.0'Douglas Christopher Wilsonbefore adoptionf6ec710
line 97why, one step back97 * or array is given, the _best_ match, if any is returned.Catch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a
lines 98–126why, one step back98 *99 * Examples:100 *101 * // Accept: text/html102 * req.accepts('html');103 * // => "html"104 *105 * // Accept: text/*, application/json106 * req.accepts('html');107 * // => "html"108 * req.accepts('text/html');109 * // => "text/html"110 * req.accepts('json, text');111 * // => "json"112 * req.accepts('application/json');113 * // => "application/json"114 *115 * // Accept: text/*, application/json116 * req.accepts('image/png');117 * req.accepts('png');118 * // => undefined119 *120 * // Accept: text/*;q=.5, application/json121 * req.accepts(['html', 'json']);122 * req.accepts('html', 'json');123 * req.accepts('html, json');124 * // => "json"125 *126 * @param {String|Array} type(s)Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
lines 127–128why, one step back127 * @return {String|Array|Boolean}128 * @publicCatch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a
lines 129–139why, one step back129 */130131req.accepts = function(){132 var accept = accepts(this);133 return accept.types.apply(accept, arguments);134};135136/**137 * Check if the given `encoding`s are accepted.138 *139 * @param {String} ...encodingMerge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
lines 140–141why, one step back140 * @return {String|Array}141 * @publicCatch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a
lines 142–153why, one step back142 */143144req.acceptsEncodings = function(){145 var accept = accepts(this);146 return accept.encodings.apply(accept, arguments);147};148149/**150 * Check if the given `charset`s are acceptable,151 * otherwise you should respond with 406 "Not Acceptable".152 *153 * @param {String} ...charsetMerge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
lines 154–155why, one step back154 * @return {String|Array}155 * @publicCatch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a
lines 156–167why, one step back156 */157158req.acceptsCharsets = function(){159 var accept = accepts(this);160 return accept.charsets.apply(accept, arguments);161};162163/**164 * Check if the given `lang`s are acceptable,165 * otherwise you should respond with 406 "Not Acceptable".166 *167 * @param {String} ...langMerge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
lines 168–169why, one step back168 * @return {String|Array}169 * @publicCatch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a
lines 170–177why, one step back170 */171172req.acceptsLanguages = function(){173 var accept = accepts(this);174 return accept.languages.apply(accept, arguments);175};176177/**Merge tag '4.14.0'Douglas Christopher Wilsonbefore adoption1dbfee6
line 178why, one step back178 * Parse Range header field, capping to the given `size`.Catch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a
line 179why, one step back179 *Merge tag '4.14.0'Douglas Christopher Wilsonbefore adoption1dbfee6
lines 180–183why, one step back180 * Unspecified ranges such as "0-" require knowledge of your resource length. In181 * the case of a byte range this is of course the total number of bytes. If the182 * Range header field is not given `undefined` is returned, `-1` when unsatisfiable,183 * and `-2` when syntactically invalid.Catch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a
line 184why, one step back184 *Merge tag '4.14.0'Douglas Christopher Wilsonbefore adoption1dbfee6
lines 185–187why, one step back185 * When ranges are returned, the array has a "type" property which is the type of186 * range that is required (most commonly, "bytes"). Each array element is an object187 * with a "start" and "end" property for the portion of the range.Catch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a
line 188why, one step back188 *Merge tag '4.14.0'Douglas Christopher Wilsonbefore adoption1dbfee6
lines 189–198why, one step back189 * The "combine" option can be set to `true` and overlapping & adjacent ranges190 * will be combined into a single range.191 *192 * NOTE: remember that ranges are inclusive, so for example "Range: users=0-3"193 * should respond with 4 users when available, not 3.194 *195 * @param {number} size196 * @param {object} [options]197 * @param {boolean} [options.combine=false]198 * @return {number|array}Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
line 199why, one step back199 * @publicCatch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a
lines 200–201why, one step back200 */201Merge tag '4.14.0'Douglas Christopher Wilsonbefore adoption1dbfee6
line 202why, one step back202req.range = function range(size, options) {Catch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a
lines 203–204why, one step back203 var range = this.get('Range');204 if (!range) return;Merge tag '4.14.0'Douglas Christopher Wilsonbefore adoption1dbfee6
line 205why, one step back205 return parseRange(size, range, options);Catch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a
lines 206–208why, one step back206};207208/**Change req.query to a getterDouglas Christopher Wilsonbefore adoptiondcc4eaa
lines 209–229why, one step back209 * Parse the query string of `req.url`.210 *211 * This uses the "query parser" setting to parse the raw212 * string into an object.213 *214 * @return {String}215 * @api public216 */217218defineGetter(req, 'query', function query(){219 var queryparse = this.app.get('query parser fn');220221 if (!queryparse) {222 // parsing is disabled223 return Object.create(null);224 }225226 var querystring = parse(this).query;227228 return queryparse(querystring);229});Catch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a
lines 230–251why, one step back230231/**232 * Check if the incoming request contains the "Content-Type"233 * header field, and it contains the give mime `type`.234 *235 * Examples:236 *237 * // With Content-Type: text/html; charset=utf-8238 * req.is('html');239 * req.is('text/html');240 * req.is('text/*');241 * // => true242 *243 * // When Content-Type is application/json244 * req.is('json');245 * req.is('application/json');246 * req.is('application/*');247 * // => true248 *249 * req.is('html');250 * // => false251 *Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
lines 252–254why, one step back252 * @param {String|Array} types...253 * @return {String|false|null}254 * @publicCatch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a
lines 255–256why, one step back255 */256Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
lines 257–268why, one step back257req.is = function is(types) {258 var arr = types;259260 // support flattened arguments261 if (!Array.isArray(types)) {262 arr = new Array(arguments.length);263 for (var i = 0; i < arr.length; i++) {264 arr[i] = arguments[i];265 }266 }267268 return typeis(this, arr);Catch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a
lines 269–274why, one step back269};270271/**272 * Return the protocol string "http" or "https"273 * when requested with TLS. When the "trust proxy"274 * setting trusts the socket address, theFix req.protocol for proxy-direct connectionsAshley Strebbefore adoption11c74d7
lines 275–277why, one step back275 * "X-Forwarded-Proto" header field will be trusted276 * and used if present.277 *Catch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a
lines 278–281why, one step back278 * If you're running behind a reverse proxy that279 * supplies https for you this may be enabled.280 *281 * @return {String}Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
line 282why, one step back282 * @publicCatch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a
lines 283–285why, one step back283 */284285defineGetter(req, 'protocol', function protocol(){Fix req.protocol for proxy-direct connectionsAshley Strebbefore adoption11c74d7
lines 286–288why, one step back286 var proto = this.connection.encrypted287 ? 'https'288 : 'http';Catch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a
lines 289–290why, one step back289 var trust = this.app.get('trust proxy fn');290Merge tag '4.12.4'Douglas Christopher Wilsonbefore adoptionf90e045
line 291why, one step back291 if (!trust(this.connection.remoteAddress, 0)) {Fix req.protocol for proxy-direct connectionsAshley Strebbefore adoption11c74d7
line 292why, one step back292 return proto;Catch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a
lines 293–296why, one step back293 }294295 // Note: X-Forwarded-Proto is normally only ever a296 // single value, but this is to be safe.Fix req.protocol for proxy-direct connectionsAshley Strebbefore adoption11c74d7
line 297why, one step back297 proto = this.get('X-Forwarded-Proto') || proto;Catch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a
lines 298–303why, one step back298 return proto.split(/\s*,\s*/)[0];299});300301/**302 * Short-hand for:303 *Merge tag '4.14.0'Douglas Christopher Wilsonbefore adoption1dbfee6
line 304why, one step back304 * req.protocol === 'https'Catch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a
lines 305–306why, one step back305 *306 * @return {Boolean}Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
line 307why, one step back307 * @publicCatch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a
lines 308–310why, one step back308 */309310defineGetter(req, 'secure', function secure(){Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
line 311why, one step back311 return this.protocol === 'https';Catch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a
lines 312–320why, one step back312});313314/**315 * Return the remote address from the trusted proxy.316 *317 * The is the remote address on the socket unless318 * "trust proxy" is set.319 *320 * @return {String}Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
line 321why, one step back321 * @publicCatch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a
lines 322–337why, one step back322 */323324defineGetter(req, 'ip', function ip(){325 var trust = this.app.get('trust proxy fn');326 return proxyaddr(this, trust);327});328329/**330 * When "trust proxy" is set, trusted proxy addresses + client.331 *332 * For example if the value were "client, proxy1, proxy2"333 * you would receive the array `["client", "proxy1", "proxy2"]`334 * where "proxy2" is the furthest down-stream and "proxy1" and335 * "proxy2" were trusted.336 *337 * @return {Array}Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
line 338why, one step back338 * @publicCatch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a
lines 339–343why, one step back339 */340341defineGetter(req, 'ips', function ips() {342 var trust = this.app.get('trust proxy fn');343 var addrs = proxyaddr.all(this, trust);Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e
lines 344–349why, one step back344345 // reverse the order (to farthest -> closest)346 // and remove socket address347 addrs.reverse().pop()348349 return addrsCatch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a
lines 350–363why, one step back350});351352/**353 * Return subdomains as an array.354 *355 * Subdomains are the dot-separated parts of the host before the main domain of356 * the app. By default, the domain of the app is assumed to be the last two357 * parts of the host. This can be changed by setting "subdomain offset".358 *359 * For example, if the domain is "tobi.ferrets.example.com":360 * If "subdomain offset" is not set, req.subdomains is `["ferrets", "tobi"]`.361 * If "subdomain offset" is 3, req.subdomains is `["tobi"]`.362 *363 * @return {Array}Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
line 364why, one step back364 * @publicCatch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a
lines 365–367why, one step back365 */366367defineGetter(req, 'subdomains', function subdomains() {Merge tag '3.17.1'Douglas Christopher Wilsonbefore adoption3dca534
lines 368–371why, one step back368 var hostname = this.hostname;369370 if (!hostname) return [];371Catch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a
line 372why, one step back372 var offset = this.app.get('subdomain offset');Merge tag '3.17.1'Douglas Christopher Wilsonbefore adoption3dca534
lines 373–377why, one step back373 var subdomains = !isIP(hostname)374 ? hostname.split('.').reverse()375 : [hostname];376377 return subdomains.slice(offset);Catch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a
lines 378–383why, one step back378});379380/**381 * Short-hand for `url.parse(req.url).pathname`.382 *383 * @return {String}Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
line 384why, one step back384 * @publicCatch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a
lines 385–391why, one step back385 */386387defineGetter(req, 'path', function path() {388 return parse(this).pathname;389});390391/**Change req.host to return hostDouglas Christopher Wilsonbefore adoption085a296
line 392why, one step back392 * Parse the "Host" header field to a host.Catch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a
lines 393–398why, one step back393 *394 * When the "trust proxy" setting trusts the socket395 * address, the "X-Forwarded-Host" header field will396 * be trusted.397 *398 * @return {String}Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
line 399why, one step back399 * @publicCatch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a
lines 400–401why, one step back400 */401Change req.host to return hostDouglas Christopher Wilsonbefore adoption085a296
line 402why, one step back402defineGetter(req, 'host', function host(){Catch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a
line 403why, one step back403 var trust = this.app.get('trust proxy fn');Change req.host to return hostDouglas Christopher Wilsonbefore adoption085a296
line 404why, one step back404 var val = this.get('X-Forwarded-Host');Catch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a
line 405why, one step back405Merge tag '4.12.4'Douglas Christopher Wilsonbefore adoptionf90e045
line 406why, one step back406 if (!val || !trust(this.connection.remoteAddress, 0)) {Change req.host to return hostDouglas Christopher Wilsonbefore adoption085a296
line 407why, one step back407 val = this.get('Host');Catch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a
lines 408–409why, one step back408 }409Change req.host to return hostDouglas Christopher Wilsonbefore adoption085a296
lines 410–426why, one step back410 return val || undefined;411});412413/**414 * Parse the "Host" header field to a hostname.415 *416 * When the "trust proxy" setting trusts the socket417 * address, the "X-Forwarded-Host" header field will418 * be trusted.419 *420 * @return {String}421 * @api public422 */423424defineGetter(req, 'hostname', function hostname(){425 var host = this.host;426Catch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a
lines 427–434why, one step back427 if (!host) return;428429 // IPv6 literal support430 var offset = host[0] === '['431 ? host.indexOf(']') + 1432 : 0;433 var index = host.indexOf(':', offset);434Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
line 435why, one step back435 return index !== -1Catch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a
lines 436–445why, one step back436 ? host.substring(0, index)437 : host;438});439440/**441 * Check if the request is fresh, aka442 * Last-Modified and/or the ETag443 * still match.444 *445 * @return {Boolean}Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
line 446why, one step back446 * @publicCatch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a
lines 447–450why, one step back447 */448449defineGetter(req, 'fresh', function(){450 var method = this.method;Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e
lines 451–452why, one step back451 var res = this.res452 var status = res.statusCodeCatch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a
lines 453–454why, one step back453454 // GET or HEAD for weak freshness validation onlyMerge tag '4.14.0'Douglas Christopher Wilsonbefore adoption1dbfee6
line 455why, one step back455 if ('GET' !== method && 'HEAD' !== method) return false;Catch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a
lines 456–457why, one step back456457 // 2xx or 304 as per rfc2616 14.26Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e
lines 458–462why, one step back458 if ((status >= 200 && status < 300) || 304 === status) {459 return fresh(this.headers, {460 'etag': res.get('ETag'),461 'last-modified': res.get('Last-Modified')462 })Catch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a
lines 463–473why, one step back463 }464465 return false;466});467468/**469 * Check if the request is stale, aka470 * "Last-Modified" and / or the "ETag" for the471 * resource has changed.472 *473 * @return {Boolean}Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
line 474why, one step back474 * @publicCatch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a
lines 475–484why, one step back475 */476477defineGetter(req, 'stale', function stale(){478 return !this.fresh;479});480481/**482 * Check if the request was an _XMLHttpRequest_.483 *484 * @return {Boolean}Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
line 485why, one step back485 * @publicCatch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a
lines 486–489why, one step back486 */487488defineGetter(req, 'xhr', function xhr(){489 var val = this.get('X-Requested-With') || '';Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
line 490why, one step back490 return val.toLowerCase() === 'xmlhttprequest';Catch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a
lines 491–498why, one step back491});492493/**494 * Helper function for creating a getter on an object.495 *496 * @param {Object} obj497 * @param {String} name498 * @param {Function} getterMerge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
line 499why, one step back499 * @privateCatch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a
lines 500–506why, one step back500 */501function defineGetter(obj, name, getter) {502 Object.defineProperty(obj, name, {503 configurable: true,504 enumerable: true,505 get: getter506 });Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e
line 507why, one step back507}