Skip to content
Myr

request.js

This file

Path

lib/request.js

514 lines · 11.4 KiB · JavaScript

Last changed by

Refactor: simplify `acceptsLanguages` implementation using spread operator (#6137)Ayoub Mabroukbefore adoption3dc9699

History of this file

Take it

The walk stopped after 200 commits: lines older than 6aa4a45 point at it.

Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87

lines 1–10why, one step back
1/*!
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';10

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 11–12why, one step back
11/**
12 * Module dependencies.

Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87

line 13why, one step back
13 * @private

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 14–16why, one step back
14 */
1516var accepts = require('accepts');

fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359

line 17why, one step back
17var isIP = require('node:net').isIP;

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

line 18why, one step back
18var typeis = require('type-is');

fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359

line 19why, one step back
19var http = require('node:http');

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 20–26why, one step back
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 back
27 * @public

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 28–29why, one step back
28 */
29

Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e

line 30why, one step back
30var req = Object.create(http.IncomingMessage.prototype)

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 31–32why, one step back
31
32/**

Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e

lines 33–39why, one step back
33 * Module exports.
34 * @public35 */3637module.exports = req3839/**

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 40–59why, one step back
40 * 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 back
60 * @public

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 61–63why, one step back
61 */
6263req.get =

Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87

line 64why, one step back
64req.header = function header(name) {

Merge tag '4.14.0'Douglas Christopher Wilsonbefore adoption1dbfee6

lines 65–72why, one step back
65 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 }72

Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87

lines 73–75why, one step back
73 var lc = name.toLowerCase();
7475 switch (lc) {

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 76–80why, one step back
76 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 back
81 return this.headers[lc];

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 82–91why, one step back
82 }
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 back
92 * The `type` value may be a single MIME type string
93 * such as "application/json", an extension name94 * such as "json", a comma-delimited list such as "json, html, text/plain",

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 95–96why, one step back
95 * an argument list such as `"json", "html", "text/plain"`,
96 * or an array `["json", "html", "text/plain"]`. When a list

Merge tag '4.12.0'Douglas Christopher Wilsonbefore adoptionf6ec710

line 97why, one step back
97 * or array is given, the _best_ match, if any is returned.

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 98–126why, one step back
98 *
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 back
127 * @return {String|Array|Boolean}
128 * @public

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 129–139why, one step back
129 */
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} ...encoding

Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87

lines 140–141why, one step back
140 * @return {String|Array}
141 * @public

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 142–153why, one step back
142 */
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} ...charset

Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87

lines 154–155why, one step back
154 * @return {String|Array}
155 * @public

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 156–167why, one step back
156 */
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} ...lang

Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87

lines 168–169why, one step back
168 * @return {String|Array}
169 * @public

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 170–171why, one step back
170 */
171

Refactor: simplify `acceptsLanguages` implementation using spread operator (#6137)Ayoub Mabroukbefore adoption3dc9699

lines 172–173why, one step back
172req.acceptsLanguages = function(...languages) {
173 return accepts(this).languages(...languages);

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 174–176why, one step back
174};
175176/**

Merge tag '4.14.0'Douglas Christopher Wilsonbefore adoption1dbfee6

line 177why, one step back
177 * Parse Range header field, capping to the given `size`.

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

line 178why, one step back
178 *

Merge tag '4.14.0'Douglas Christopher Wilsonbefore adoption1dbfee6

lines 179–182why, one step back
179 * Unspecified ranges such as "0-" require knowledge of your resource length. In
180 * the case of a byte range this is of course the total number of bytes. If the181 * Range header field is not given `undefined` is returned, `-1` when unsatisfiable,182 * and `-2` when syntactically invalid.

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

line 183why, one step back
183 *

Merge tag '4.14.0'Douglas Christopher Wilsonbefore adoption1dbfee6

lines 184–186why, one step back
184 * When ranges are returned, the array has a "type" property which is the type of
185 * range that is required (most commonly, "bytes"). Each array element is an object186 * with a "start" and "end" property for the portion of the range.

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

line 187why, one step back
187 *

Merge tag '4.14.0'Douglas Christopher Wilsonbefore adoption1dbfee6

lines 188–197why, one step back
188 * The "combine" option can be set to `true` and overlapping & adjacent ranges
189 * will be combined into a single range.190 *191 * NOTE: remember that ranges are inclusive, so for example "Range: users=0-3"192 * should respond with 4 users when available, not 3.193 *194 * @param {number} size195 * @param {object} [options]196 * @param {boolean} [options.combine=false]197 * @return {number|array}

Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87

line 198why, one step back
198 * @public

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 199–200why, one step back
199 */
200

Merge tag '4.14.0'Douglas Christopher Wilsonbefore adoption1dbfee6

line 201why, one step back
201req.range = function range(size, options) {

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 202–203why, one step back
202 var range = this.get('Range');
203 if (!range) return;

Merge tag '4.14.0'Douglas Christopher Wilsonbefore adoption1dbfee6

line 204why, one step back
204 return parseRange(size, range, options);

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 205–207why, one step back
205};
206207/**

Change req.query to a getterDouglas Christopher Wilsonbefore adoptiondcc4eaa

lines 208–228why, one step back
208 * Parse the query string of `req.url`.
209 *210 * This uses the "query parser" setting to parse the raw211 * string into an object.212 *213 * @return {String}214 * @api public215 */216217defineGetter(req, 'query', function query(){218 var queryparse = this.app.get('query parser fn');219220 if (!queryparse) {221 // parsing is disabled222 return Object.create(null);223 }224225 var querystring = parse(this).query;226227 return queryparse(querystring);228});

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 229–231why, one step back
229
230/**231 * Check if the incoming request contains the "Content-Type"

Merge tag '4.17.2'Douglas Christopher Wilsonbefore adoptionc7d528c

line 232why, one step back
232 * header field, and it contains the given mime `type`.

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 233–250why, one step back
233 *
234 * Examples:235 *236 * // With Content-Type: text/html; charset=utf-8237 * req.is('html');238 * req.is('text/html');239 * req.is('text/*');240 * // => true241 *242 * // When Content-Type is application/json243 * req.is('json');244 * req.is('application/json');245 * req.is('application/*');246 * // => true247 *248 * req.is('html');249 * // => false250 *

Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87

lines 251–253why, one step back
251 * @param {String|Array} types...
252 * @return {String|false|null}253 * @public

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 254–255why, one step back
254 */
255

Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87

lines 256–267why, one step back
256req.is = function is(types) {
257 var arr = types;258259 // support flattened arguments260 if (!Array.isArray(types)) {261 arr = new Array(arguments.length);262 for (var i = 0; i < arr.length; i++) {263 arr[i] = arguments[i];264 }265 }266267 return typeis(this, arr);

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 268–280why, one step back
268};
269270/**271 * Return the protocol string "http" or "https"272 * when requested with TLS. When the "trust proxy"273 * setting trusts the socket address, the274 * "X-Forwarded-Proto" header field will be trusted275 * and used if present.276 *277 * If you're running behind a reverse proxy that278 * supplies https for you this may be enabled.279 *280 * @return {String}

Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87

line 281why, one step back
281 * @public

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 282–289why, one step back
282 */
283284defineGetter(req, 'protocol', function protocol(){285 var proto = this.connection.encrypted286 ? 'https'287 : 'http';288 var trust = this.app.get('trust proxy fn');289

Merge tag '4.12.4'Douglas Christopher Wilsonbefore adoptionf90e045

line 290why, one step back
290 if (!trust(this.connection.remoteAddress, 0)) {

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 291–295why, one step back
291 return proto;
292 }293294 // Note: X-Forwarded-Proto is normally only ever a295 // single value, but this is to be safe.

Merge tag '4.16.2'Douglas Christopher Wilsonbefore adoption62e12fe

lines 296–301why, one step back
296 var header = this.get('X-Forwarded-Proto') || proto
297 var index = header.indexOf(',')298299 return index !== -1300 ? header.substring(0, index).trim()301 : header.trim()

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 302–306why, one step back
302});
303304/**305 * Short-hand for:306 *

Merge tag '4.14.0'Douglas Christopher Wilsonbefore adoption1dbfee6

line 307why, one step back
307 * req.protocol === 'https'

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 308–309why, one step back
308 *
309 * @return {Boolean}

Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87

line 310why, one step back
310 * @public

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 311–313why, one step back
311 */
312313defineGetter(req, 'secure', function secure(){

Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87

line 314why, one step back
314 return this.protocol === 'https';

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 315–323why, one step back
315});
316317/**318 * Return the remote address from the trusted proxy.319 *320 * The is the remote address on the socket unless321 * "trust proxy" is set.322 *323 * @return {String}

Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87

line 324why, one step back
324 * @public

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 325–340why, one step back
325 */
326327defineGetter(req, 'ip', function ip(){328 var trust = this.app.get('trust proxy fn');329 return proxyaddr(this, trust);330});331332/**333 * When "trust proxy" is set, trusted proxy addresses + client.334 *335 * For example if the value were "client, proxy1, proxy2"336 * you would receive the array `["client", "proxy1", "proxy2"]`337 * where "proxy2" is the furthest down-stream and "proxy1" and338 * "proxy2" were trusted.339 *340 * @return {Array}

Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87

line 341why, one step back
341 * @public

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 342–346why, one step back
342 */
343344defineGetter(req, 'ips', function ips() {345 var trust = this.app.get('trust proxy fn');346 var addrs = proxyaddr.all(this, trust);

Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e

lines 347–352why, one step back
347
348 // reverse the order (to farthest -> closest)349 // and remove socket address350 addrs.reverse().pop()351352 return addrs

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 353–366why, one step back
353});
354355/**356 * Return subdomains as an array.357 *358 * Subdomains are the dot-separated parts of the host before the main domain of359 * the app. By default, the domain of the app is assumed to be the last two360 * parts of the host. This can be changed by setting "subdomain offset".361 *362 * For example, if the domain is "tobi.ferrets.example.com":363 * If "subdomain offset" is not set, req.subdomains is `["ferrets", "tobi"]`.364 * If "subdomain offset" is 3, req.subdomains is `["tobi"]`.365 *366 * @return {Array}

Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87

line 367why, one step back
367 * @public

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 368–386why, one step back
368 */
369370defineGetter(req, 'subdomains', function subdomains() {371 var hostname = this.hostname;372373 if (!hostname) return [];374375 var offset = this.app.get('subdomain offset');376 var subdomains = !isIP(hostname)377 ? hostname.split('.').reverse()378 : [hostname];379380 return subdomains.slice(offset);381});382383/**384 * Short-hand for `url.parse(req.url).pathname`.385 *386 * @return {String}

Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87

line 387why, one step back
387 * @public

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 388–394why, one step back
388 */
389390defineGetter(req, 'path', function path() {391 return parse(this).pathname;392});393394/**

Change req.host to return hostDouglas Christopher Wilsonbefore adoption085a296

line 395why, one step back
395 * Parse the "Host" header field to a host.

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 396–401why, one step back
396 *
397 * When the "trust proxy" setting trusts the socket398 * address, the "X-Forwarded-Host" header field will399 * be trusted.400 *401 * @return {String}

Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87

line 402why, one step back
402 * @public

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 403–404why, one step back
403 */
404

Change req.host to return hostDouglas Christopher Wilsonbefore adoption085a296

line 405why, one step back
405defineGetter(req, 'host', function host(){

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

line 406why, one step back
406 var trust = this.app.get('trust proxy fn');

Change req.host to return hostDouglas Christopher Wilsonbefore adoption085a296

line 407why, one step back
407 var val = this.get('X-Forwarded-Host');

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

line 408why, one step back
408

Merge tag '4.12.4'Douglas Christopher Wilsonbefore adoptionf90e045

line 409why, one step back
409 if (!val || !trust(this.connection.remoteAddress, 0)) {

Change req.host to return hostDouglas Christopher Wilsonbefore adoption085a296

line 410why, one step back
410 val = this.get('Host');

Merge tag '4.17.1'Douglas Christopher Wilsonbefore adoption121fe99

lines 411–414why, one step back
411 } else if (val.indexOf(',') !== -1) {
412 // Note: X-Forwarded-Host is normally only ever a413 // single value, but this is to be safe.414 val = val.substring(0, val.indexOf(',')).trimRight()

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 415–416why, one step back
415 }
416

Change req.host to return hostDouglas Christopher Wilsonbefore adoption085a296

lines 417–433why, one step back
417 return val || undefined;
418});419420/**421 * Parse the "Host" header field to a hostname.422 *423 * When the "trust proxy" setting trusts the socket424 * address, the "X-Forwarded-Host" header field will425 * be trusted.426 *427 * @return {String}428 * @api public429 */430431defineGetter(req, 'hostname', function hostname(){432 var host = this.host;433

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 434–441why, one step back
434 if (!host) return;
435436 // IPv6 literal support437 var offset = host[0] === '['438 ? host.indexOf(']') + 1439 : 0;440 var index = host.indexOf(':', offset);441

Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87

line 442why, one step back
442 return index !== -1

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 443–448why, one step back
443 ? host.substring(0, index)
444 : host;445});446447/**448 * Check if the request is fresh, aka

Merge branch '5.0' into 5-mergeWes Toddbefore adoptionf9256ef

line 449why, one step back
449 * Last-Modified or the ETag

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 450–452why, one step back
450 * still match.
451 *452 * @return {Boolean}

Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87

line 453why, one step back
453 * @public

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 454–457why, one step back
454 */
455456defineGetter(req, 'fresh', function(){457 var method = this.method;

Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e

lines 458–459why, one step back
458 var res = this.res
459 var status = res.statusCode

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 460–461why, one step back
460
461 // GET or HEAD for weak freshness validation only

Merge tag '4.14.0'Douglas Christopher Wilsonbefore adoption1dbfee6

line 462why, one step back
462 if ('GET' !== method && 'HEAD' !== method) return false;

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 463–464why, one step back
463
464 // 2xx or 304 as per rfc2616 14.26

Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e

lines 465–469why, one step back
465 if ((status >= 200 && status < 300) || 304 === status) {
466 return fresh(this.headers, {467 'etag': res.get('ETag'),468 'last-modified': res.get('Last-Modified')469 })

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 470–480why, one step back
470 }
471472 return false;473});474475/**476 * Check if the request is stale, aka477 * "Last-Modified" and / or the "ETag" for the478 * resource has changed.479 *480 * @return {Boolean}

Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87

line 481why, one step back
481 * @public

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 482–491why, one step back
482 */
483484defineGetter(req, 'stale', function stale(){485 return !this.fresh;486});487488/**489 * Check if the request was an _XMLHttpRequest_.490 *491 * @return {Boolean}

Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87

line 492why, one step back
492 * @public

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 493–496why, one step back
493 */
494495defineGetter(req, 'xhr', function xhr(){496 var val = this.get('X-Requested-With') || '';

Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87

line 497why, one step back
497 return val.toLowerCase() === 'xmlhttprequest';

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 498–505why, one step back
498});
499500/**501 * Helper function for creating a getter on an object.502 *503 * @param {Object} obj504 * @param {String} name505 * @param {Function} getter

Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87

line 506why, one step back
506 * @private

Merge tag '3.17.7'Douglas Christopher Wilsonbefore adoption6aa4a45

lines 507–513why, one step back
507 */
508function defineGetter(obj, name, getter) {509 Object.defineProperty(obj, name, {510 configurable: true,511 enumerable: true,512 get: getter513 });

Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e

line 514why, one step back
514}