axios 0.33.0 → 0.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/README.md +70 -1
- package/dist/axios.js +416 -50
- package/dist/axios.js.map +1 -1
- package/dist/axios.min.js +1 -1
- package/dist/axios.min.js.map +1 -1
- package/dist/esm/axios.js +416 -50
- package/dist/esm/axios.js.map +1 -1
- package/dist/esm/axios.min.js +1 -1
- package/dist/esm/axios.min.js.map +1 -1
- package/index.d.ts +5 -1
- package/lib/adapters/http.js +107 -14
- package/lib/adapters/xhr.js +2 -2
- package/lib/cancel/fromSignal.js +20 -0
- package/lib/core/Axios.js +107 -24
- package/lib/core/dispatchRequest.js +5 -4
- package/lib/core/mergeConfig.js +10 -0
- package/lib/env/data.js +1 -1
- package/lib/helpers/assertParamsDepth.js +100 -0
- package/lib/helpers/estimateDataURLDecodedBytes.js +3 -3
- package/lib/helpers/formDataToJSON.js +40 -3
- package/lib/helpers/getDirectAgent.js +85 -0
- package/lib/helpers/shouldBypassProxy.js +229 -2
- package/lib/helpers/toFormData.js +39 -12
- package/lib/utils.js +101 -5
- package/package.json +1 -1
package/dist/esm/axios.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// axios v0.
|
|
1
|
+
// axios v0.35.0 Copyright (c) 2026 Matt Zabriskie
|
|
2
2
|
var bind = function bind(fn, thisArg) {
|
|
3
3
|
return function wrap() {
|
|
4
4
|
return fn.apply(thisArg, arguments);
|
|
@@ -396,6 +396,15 @@ function stripBOM(content) {
|
|
|
396
396
|
return content;
|
|
397
397
|
}
|
|
398
398
|
|
|
399
|
+
function defineOwnProperty(target, key, value) {
|
|
400
|
+
var descriptor = Object.create(null);
|
|
401
|
+
descriptor.value = value;
|
|
402
|
+
descriptor.writable = true;
|
|
403
|
+
descriptor.enumerable = true;
|
|
404
|
+
descriptor.configurable = true;
|
|
405
|
+
Object.defineProperty(target, key, descriptor);
|
|
406
|
+
}
|
|
407
|
+
|
|
399
408
|
/**
|
|
400
409
|
* Inherit the prototype methods from one constructor into another
|
|
401
410
|
* @param {function} constructor
|
|
@@ -403,14 +412,35 @@ function stripBOM(content) {
|
|
|
403
412
|
* @param {object} [props]
|
|
404
413
|
* @param {object} [descriptors]
|
|
405
414
|
*/
|
|
406
|
-
|
|
407
415
|
function inherits(constructor, superConstructor, props, descriptors) {
|
|
408
416
|
constructor.prototype = Object.create(
|
|
409
417
|
superConstructor.prototype,
|
|
410
418
|
descriptors
|
|
411
419
|
);
|
|
412
|
-
|
|
413
|
-
|
|
420
|
+
if (Object.prototype.hasOwnProperty.call(constructor.prototype, 'constructor')) {
|
|
421
|
+
constructor.prototype.constructor = constructor;
|
|
422
|
+
} else {
|
|
423
|
+
defineOwnProperty(constructor.prototype, 'constructor', constructor);
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
if (props) {
|
|
427
|
+
var keys = Object.keys(props);
|
|
428
|
+
if (Object.getOwnPropertySymbols) {
|
|
429
|
+
keys = keys.concat(Object.getOwnPropertySymbols(props).filter(function(key) {
|
|
430
|
+
return Object.prototype.propertyIsEnumerable.call(props, key);
|
|
431
|
+
}));
|
|
432
|
+
}
|
|
433
|
+
keys.forEach(function(key) {
|
|
434
|
+
var value = props[key];
|
|
435
|
+
if (Object.prototype.hasOwnProperty.call(constructor.prototype, key)) {
|
|
436
|
+
constructor.prototype[key] = value;
|
|
437
|
+
} else {
|
|
438
|
+
// Assignment would invoke an inherited setter or fail on a read-only
|
|
439
|
+
// property installed by another library, such as Error.prototype.toJSON.
|
|
440
|
+
defineOwnProperty(constructor.prototype, key, value);
|
|
441
|
+
}
|
|
442
|
+
});
|
|
443
|
+
}
|
|
414
444
|
}
|
|
415
445
|
|
|
416
446
|
/**
|
|
@@ -481,10 +511,75 @@ function toArray(thing) {
|
|
|
481
511
|
if (!thing) return null;
|
|
482
512
|
if (isArray(thing)) return thing;
|
|
483
513
|
var i = thing.length;
|
|
484
|
-
if (
|
|
514
|
+
if (typeof i !== 'number' || i < 0 || i > 0xffffffff || Math.floor(i) !== i) return null;
|
|
515
|
+
|
|
516
|
+
// Legacy FileList hosts expose indexed reads without reflecting their keys.
|
|
517
|
+
if (isFileList(thing)) {
|
|
518
|
+
var files = [];
|
|
519
|
+
while (i-- > 0) {
|
|
520
|
+
var file = thing[i];
|
|
521
|
+
if (file === null || isUndefined(file)) return null;
|
|
522
|
+
defineOwnProperty(files, i, file);
|
|
523
|
+
}
|
|
524
|
+
return files;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
// Count actual indexes, including hidden collection properties, before
|
|
528
|
+
// allocating from the declared length. Box primitives for ES5 object APIs.
|
|
529
|
+
var source = Object(thing);
|
|
530
|
+
var indexes = Object.create(null);
|
|
531
|
+
var count = 0;
|
|
532
|
+
var seen = [];
|
|
533
|
+
var owns = Object.prototype.hasOwnProperty;
|
|
534
|
+
|
|
535
|
+
while (source && count < i) {
|
|
536
|
+
if (seen.indexOf(source) !== -1) return null;
|
|
537
|
+
defineOwnProperty(seen, seen.length, source);
|
|
538
|
+
|
|
539
|
+
if (source === Object.prototype) break;
|
|
540
|
+
|
|
541
|
+
var prototype = Object.getPrototypeOf(source);
|
|
542
|
+
if (prototype === null) {
|
|
543
|
+
var constructorDescriptor = Object.getOwnPropertyDescriptor(source, 'constructor');
|
|
544
|
+
var constructorValue = constructorDescriptor && owns.call(constructorDescriptor, 'value') &&
|
|
545
|
+
constructorDescriptor.value;
|
|
546
|
+
var constructorPrototype = typeof constructorValue === 'function' &&
|
|
547
|
+
Object.getOwnPropertyDescriptor(constructorValue, 'prototype');
|
|
548
|
+
|
|
549
|
+
// Recognize another realm's Object.prototype without excluding
|
|
550
|
+
// application-defined null-prototype parents or invoking accessors.
|
|
551
|
+
if (
|
|
552
|
+
constructorPrototype && owns.call(constructorPrototype, 'value') &&
|
|
553
|
+
constructorPrototype.value === source &&
|
|
554
|
+
Function.prototype.toString.call(constructorValue) === Function.prototype.toString.call(Object)
|
|
555
|
+
) {
|
|
556
|
+
break;
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
var keys = Object.getOwnPropertyNames(source);
|
|
561
|
+
for (var j = 0; j < keys.length; j++) {
|
|
562
|
+
var key = keys[j];
|
|
563
|
+
var index = +key;
|
|
564
|
+
if (
|
|
565
|
+
index >= 0 &&
|
|
566
|
+
index < i &&
|
|
567
|
+
Math.floor(index) === index &&
|
|
568
|
+
String(index) === key &&
|
|
569
|
+
owns.call(source, key) &&
|
|
570
|
+
!indexes[key]
|
|
571
|
+
) {
|
|
572
|
+
indexes[key] = true;
|
|
573
|
+
count++;
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
source = prototype;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
if (count !== i) return null;
|
|
485
580
|
var arr = new Array(i);
|
|
486
581
|
while (i-- > 0) {
|
|
487
|
-
arr
|
|
582
|
+
defineOwnProperty(arr, i, thing[i]);
|
|
488
583
|
}
|
|
489
584
|
return arr;
|
|
490
585
|
}
|
|
@@ -554,6 +649,7 @@ var utils = {
|
|
|
554
649
|
trim: trim,
|
|
555
650
|
stripBOM: stripBOM,
|
|
556
651
|
inherits: inherits,
|
|
652
|
+
defineOwnProperty: defineOwnProperty,
|
|
557
653
|
toFlatObject: toFlatObject,
|
|
558
654
|
kindOf: kindOf,
|
|
559
655
|
kindOfTest: kindOfTest,
|
|
@@ -773,6 +869,40 @@ function isSpecCompliant(thing) {
|
|
|
773
869
|
return thing && utils.isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator];
|
|
774
870
|
}
|
|
775
871
|
|
|
872
|
+
var UNSAFE_OPTION_KEYS = ['__proto__', 'constructor', 'prototype'];
|
|
873
|
+
|
|
874
|
+
// Materialises the serializer options onto a null-prototype object. Reading the
|
|
875
|
+
// options from a plain object let a polluted Object.prototype supply a visitor,
|
|
876
|
+
// a depth limit, a Blob implementation or key-format flags that the caller never
|
|
877
|
+
// asked for, and also let a polluted key mask an option the caller did set.
|
|
878
|
+
// Only own, defined properties of the caller's options are carried over.
|
|
879
|
+
function toFormDataOptions(source) {
|
|
880
|
+
var options = Object.create(null);
|
|
881
|
+
|
|
882
|
+
options.metaTokens = true;
|
|
883
|
+
options.dots = false;
|
|
884
|
+
options.indexes = false;
|
|
885
|
+
|
|
886
|
+
// eslint-disable-next-line no-eq-null,eqeqeq
|
|
887
|
+
if (source == null) {
|
|
888
|
+
return options;
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
var names = Object.getOwnPropertyNames(source);
|
|
892
|
+
|
|
893
|
+
for (var i = 0; i < names.length; i++) {
|
|
894
|
+
var name = names[i];
|
|
895
|
+
|
|
896
|
+
if (UNSAFE_OPTION_KEYS.indexOf(name) !== -1 || utils.isUndefined(source[name])) {
|
|
897
|
+
continue;
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
options[name] = source[name];
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
return options;
|
|
904
|
+
}
|
|
905
|
+
|
|
776
906
|
/**
|
|
777
907
|
* Convert a data object to FormData
|
|
778
908
|
* @param {Object} obj
|
|
@@ -794,14 +924,7 @@ function toFormData(obj, formData, options) {
|
|
|
794
924
|
formData = formData || new (FormData$1 || FormData)();
|
|
795
925
|
|
|
796
926
|
// eslint-disable-next-line no-param-reassign
|
|
797
|
-
options =
|
|
798
|
-
metaTokens: true,
|
|
799
|
-
dots: false,
|
|
800
|
-
indexes: false
|
|
801
|
-
}, false, function defined(option, source) {
|
|
802
|
-
// eslint-disable-next-line no-eq-null,eqeqeq
|
|
803
|
-
return !utils.isUndefined(source[option]);
|
|
804
|
-
});
|
|
927
|
+
options = toFormDataOptions(options);
|
|
805
928
|
|
|
806
929
|
var metaTokens = options.metaTokens;
|
|
807
930
|
// eslint-disable-next-line no-use-before-define
|
|
@@ -848,7 +971,7 @@ function toFormData(obj, formData, options) {
|
|
|
848
971
|
return;
|
|
849
972
|
}
|
|
850
973
|
|
|
851
|
-
stack.
|
|
974
|
+
utils.defineOwnProperty(stack, stack.length, value);
|
|
852
975
|
|
|
853
976
|
utils.forEach(value, function each(el) {
|
|
854
977
|
assertValueDepth(el, depth + 1);
|
|
@@ -877,8 +1000,8 @@ function toFormData(obj, formData, options) {
|
|
|
877
1000
|
value = JSON.stringify(value);
|
|
878
1001
|
} else if (
|
|
879
1002
|
(utils.isArray(value) && isFlatArray(value)) ||
|
|
880
|
-
(utils.isFileList(value) || utils.endsWith(key, '[]') && (arr = utils.toArray(value))
|
|
881
|
-
|
|
1003
|
+
((utils.isFileList(value) || utils.endsWith(key, '[]')) && (arr = utils.toArray(value)))
|
|
1004
|
+
) {
|
|
882
1005
|
// eslint-disable-next-line no-param-reassign
|
|
883
1006
|
key = removeBrackets(key);
|
|
884
1007
|
|
|
@@ -925,7 +1048,7 @@ function toFormData(obj, formData, options) {
|
|
|
925
1048
|
throw Error('Circular reference detected in ' + path.join('.'));
|
|
926
1049
|
}
|
|
927
1050
|
|
|
928
|
-
stack.
|
|
1051
|
+
utils.defineOwnProperty(stack, stack.length, value);
|
|
929
1052
|
|
|
930
1053
|
utils.forEach(value, function each(el, key) {
|
|
931
1054
|
var result = !(utils.isUndefined(el) || el === null) && visitor.call(
|
|
@@ -1197,13 +1320,50 @@ function arrayToObject(arr) {
|
|
|
1197
1320
|
return obj;
|
|
1198
1321
|
}
|
|
1199
1322
|
|
|
1323
|
+
function normalizeArray(value) {
|
|
1324
|
+
if (!utils.isArray(value)) return value;
|
|
1325
|
+
|
|
1326
|
+
var keys = Object.keys(value);
|
|
1327
|
+
if (keys.length !== value.length) return arrayToObject(value);
|
|
1328
|
+
|
|
1329
|
+
for (var i = 0; i < keys.length; i++) {
|
|
1330
|
+
var index = +keys[i];
|
|
1331
|
+
if (
|
|
1332
|
+
index < 0 || index >= value.length ||
|
|
1333
|
+
Math.floor(index) !== index || String(index) !== keys[i]
|
|
1334
|
+
) {
|
|
1335
|
+
return arrayToObject(value);
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1339
|
+
return value;
|
|
1340
|
+
}
|
|
1341
|
+
|
|
1342
|
+
function normalizeArrays(obj) {
|
|
1343
|
+
var pending = [obj];
|
|
1344
|
+
function normalizeEntry(target, key) {
|
|
1345
|
+
var value = target[key] = normalizeArray(target[key]);
|
|
1346
|
+
if (utils.isArray(value) || utils.isPlainObject(value)) {
|
|
1347
|
+
pending.push(value);
|
|
1348
|
+
}
|
|
1349
|
+
}
|
|
1350
|
+
while (pending.length) {
|
|
1351
|
+
var target = pending.pop();
|
|
1352
|
+
var keys = Object.keys(target);
|
|
1353
|
+
for (var i = 0; i < keys.length; i++) {
|
|
1354
|
+
normalizeEntry(target, keys[i]);
|
|
1355
|
+
}
|
|
1356
|
+
}
|
|
1357
|
+
return obj;
|
|
1358
|
+
}
|
|
1359
|
+
|
|
1200
1360
|
function formDataToJSON(formData) {
|
|
1201
1361
|
function buildPath(path, value, target, index) {
|
|
1202
1362
|
var name = path[index++];
|
|
1203
1363
|
|
|
1204
1364
|
if (name === '__proto__') return true;
|
|
1205
1365
|
|
|
1206
|
-
var isNumericKey =
|
|
1366
|
+
var isNumericKey = isFinite(+name);
|
|
1207
1367
|
var isLast = index >= path.length;
|
|
1208
1368
|
name = !name && utils.isArray(target) ? target.length : name;
|
|
1209
1369
|
|
|
@@ -1217,7 +1377,7 @@ function formDataToJSON(formData) {
|
|
|
1217
1377
|
return !isNumericKey;
|
|
1218
1378
|
}
|
|
1219
1379
|
|
|
1220
|
-
if (!target
|
|
1380
|
+
if (!utils.hasOwnProperty(target, name) || !utils.isObject(target[name])) {
|
|
1221
1381
|
target[name] = [];
|
|
1222
1382
|
}
|
|
1223
1383
|
|
|
@@ -1240,7 +1400,7 @@ function formDataToJSON(formData) {
|
|
|
1240
1400
|
buildPath(path, value, obj, 0);
|
|
1241
1401
|
});
|
|
1242
1402
|
|
|
1243
|
-
return obj;
|
|
1403
|
+
return normalizeArrays(obj);
|
|
1244
1404
|
}
|
|
1245
1405
|
|
|
1246
1406
|
return null;
|
|
@@ -1513,6 +1673,23 @@ utils.inherits(CanceledError, AxiosError_1, {
|
|
|
1513
1673
|
|
|
1514
1674
|
var CanceledError_1 = CanceledError;
|
|
1515
1675
|
|
|
1676
|
+
var fromSignal = function fromSignal(signal, config, request) {
|
|
1677
|
+
var error = new CanceledError_1(null, config, request);
|
|
1678
|
+
|
|
1679
|
+
if (signal) {
|
|
1680
|
+
try {
|
|
1681
|
+
var reason = signal.reason;
|
|
1682
|
+
if (reason !== undefined) {
|
|
1683
|
+
error.reason = reason;
|
|
1684
|
+
}
|
|
1685
|
+
} catch (e) {
|
|
1686
|
+
// A custom signal getter must not prevent cancellation.
|
|
1687
|
+
}
|
|
1688
|
+
}
|
|
1689
|
+
|
|
1690
|
+
return error;
|
|
1691
|
+
};
|
|
1692
|
+
|
|
1516
1693
|
var parseProtocol = function parseProtocol(url) {
|
|
1517
1694
|
var match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
|
|
1518
1695
|
return match && match[1] || '';
|
|
@@ -1766,7 +1943,7 @@ var xhr = function xhrAdapter(config) {
|
|
|
1766
1943
|
}
|
|
1767
1944
|
reject(
|
|
1768
1945
|
!cancel || cancel.type
|
|
1769
|
-
?
|
|
1946
|
+
? fromSignal(config.signal, config, request)
|
|
1770
1947
|
: cancel
|
|
1771
1948
|
);
|
|
1772
1949
|
request.abort();
|
|
@@ -2030,7 +2207,7 @@ function throwIfCancellationRequested(config) {
|
|
|
2030
2207
|
}
|
|
2031
2208
|
|
|
2032
2209
|
if (config.signal && config.signal.aborted) {
|
|
2033
|
-
throw
|
|
2210
|
+
throw fromSignal(config.signal, config);
|
|
2034
2211
|
}
|
|
2035
2212
|
}
|
|
2036
2213
|
|
|
@@ -2043,8 +2220,9 @@ function throwIfCancellationRequested(config) {
|
|
|
2043
2220
|
var dispatchRequest = function dispatchRequest(config) {
|
|
2044
2221
|
throwIfCancellationRequested(config);
|
|
2045
2222
|
|
|
2046
|
-
// Ensure headers exist
|
|
2047
|
-
|
|
2223
|
+
// Ensure headers exist. A request interceptor may return a replacement config
|
|
2224
|
+
// that inherits from Object.prototype, so only an own headers value is used.
|
|
2225
|
+
config.headers = (utils.hasOwnProperty(config, 'headers') && config.headers) || {};
|
|
2048
2226
|
|
|
2049
2227
|
// Transform request data
|
|
2050
2228
|
config.data = transformData.call(
|
|
@@ -2116,6 +2294,102 @@ var dispatchRequest = function dispatchRequest(config) {
|
|
|
2116
2294
|
});
|
|
2117
2295
|
};
|
|
2118
2296
|
|
|
2297
|
+
// Match numeric array reads without scanning unoccupied slots or metadata.
|
|
2298
|
+
function arrayIndexes(array) {
|
|
2299
|
+
var length = array.length;
|
|
2300
|
+
var indexes = Object.create(null);
|
|
2301
|
+
var keys = [];
|
|
2302
|
+
var source = array;
|
|
2303
|
+
var fast = array;
|
|
2304
|
+
while (source) {
|
|
2305
|
+
var names = Object.getOwnPropertyNames(source);
|
|
2306
|
+
for (var i = 0; i < names.length; i++) {
|
|
2307
|
+
var key = names[i];
|
|
2308
|
+
var index = +key;
|
|
2309
|
+
if (index >= 0 && index < length && Math.floor(index) === index &&
|
|
2310
|
+
String(index) === key && !indexes[key]) {
|
|
2311
|
+
indexes[key] = true;
|
|
2312
|
+
keys.push(key);
|
|
2313
|
+
}
|
|
2314
|
+
}
|
|
2315
|
+
source = Object.getPrototypeOf(source);
|
|
2316
|
+
// Detect unusual cyclic prototype chains with constant memory.
|
|
2317
|
+
fast = fast && Object.getPrototypeOf(fast);
|
|
2318
|
+
fast = fast && Object.getPrototypeOf(fast);
|
|
2319
|
+
if (source && source === fast) {
|
|
2320
|
+
throw new AxiosError_1('Circular prototype chain in params', AxiosError_1.ERR_BAD_OPTION_VALUE);
|
|
2321
|
+
}
|
|
2322
|
+
}
|
|
2323
|
+
return keys.sort(function(a, b) { return a - b; });
|
|
2324
|
+
}
|
|
2325
|
+
|
|
2326
|
+
var assertParamsDepth = function assertParamsDepth(params) {
|
|
2327
|
+
if (!utils.isObject(params)) return;
|
|
2328
|
+
var pending = [{ value: params, depth: 0, complete: false }];
|
|
2329
|
+
var ancestors = [];
|
|
2330
|
+
var visited = null;
|
|
2331
|
+
if (typeof WeakMap === 'function') {
|
|
2332
|
+
visited = new WeakMap();
|
|
2333
|
+
} else if (typeof Map === 'function') {
|
|
2334
|
+
visited = new Map();
|
|
2335
|
+
}
|
|
2336
|
+
// Older runtimes can only compare immutable object identities by scanning.
|
|
2337
|
+
// Keep that scan bounded; recently completed subgraphs avoid repeated work,
|
|
2338
|
+
// while evicted shared subgraphs may be visited again.
|
|
2339
|
+
var cacheSize = 128;
|
|
2340
|
+
var visitedValues = [];
|
|
2341
|
+
var visitedDepths = [];
|
|
2342
|
+
var nextCacheIndex = 0;
|
|
2343
|
+
while (pending.length) {
|
|
2344
|
+
var entry = pending.pop();
|
|
2345
|
+
var value = entry.value;
|
|
2346
|
+
var index;
|
|
2347
|
+
if (entry.complete) {
|
|
2348
|
+
ancestors.pop();
|
|
2349
|
+
if (visited) {
|
|
2350
|
+
visited.set(value, entry.depth);
|
|
2351
|
+
} else {
|
|
2352
|
+
index = visitedValues.indexOf(value);
|
|
2353
|
+
if (index === -1) {
|
|
2354
|
+
index = nextCacheIndex;
|
|
2355
|
+
nextCacheIndex = (nextCacheIndex + 1) % cacheSize;
|
|
2356
|
+
}
|
|
2357
|
+
visitedValues[index] = value;
|
|
2358
|
+
visitedDepths[index] = entry.depth;
|
|
2359
|
+
}
|
|
2360
|
+
continue;
|
|
2361
|
+
}
|
|
2362
|
+
// The serializer enumerates any object at its root, then recursively
|
|
2363
|
+
// visits only plain objects and arrays below that root.
|
|
2364
|
+
if (entry.depth === 0 ? !utils.isObject(value) :
|
|
2365
|
+
!utils.isPlainObject(value) && !utils.isArray(value)) {
|
|
2366
|
+
continue;
|
|
2367
|
+
}
|
|
2368
|
+
if (entry.depth > 100) {
|
|
2369
|
+
throw new AxiosError_1('params exceed the maximum depth of 100', AxiosError_1.ERR_BAD_OPTION_VALUE);
|
|
2370
|
+
}
|
|
2371
|
+
// The depth cap bounds this ancestry scan independently of params width.
|
|
2372
|
+
if (ancestors.indexOf(value) !== -1) {
|
|
2373
|
+
throw new AxiosError_1('Circular reference detected in params', AxiosError_1.ERR_BAD_OPTION_VALUE);
|
|
2374
|
+
}
|
|
2375
|
+
if (visited) {
|
|
2376
|
+
if (visited.has(value) && visited.get(value) >= entry.depth) continue;
|
|
2377
|
+
} else {
|
|
2378
|
+
index = visitedValues.indexOf(value);
|
|
2379
|
+
if (index !== -1 && visitedDepths[index] >= entry.depth) continue;
|
|
2380
|
+
}
|
|
2381
|
+
ancestors.push(value);
|
|
2382
|
+
pending.push({ value: value, depth: entry.depth, complete: true });
|
|
2383
|
+
var keys = utils.isArray(value) ? arrayIndexes(value) : Object.keys(value);
|
|
2384
|
+
for (var i = 0; i < keys.length; i++) {
|
|
2385
|
+
var key = keys[i];
|
|
2386
|
+
if (key !== '__proto__' && key !== 'constructor' && key !== 'prototype') {
|
|
2387
|
+
pending.push({ value: value[key], depth: entry.depth + 1, complete: false });
|
|
2388
|
+
}
|
|
2389
|
+
}
|
|
2390
|
+
}
|
|
2391
|
+
};
|
|
2392
|
+
|
|
2119
2393
|
/**
|
|
2120
2394
|
* Config-specific merge-function which creates a new config-object
|
|
2121
2395
|
* by merging two configuration objects together.
|
|
@@ -2127,6 +2401,8 @@ var dispatchRequest = function dispatchRequest(config) {
|
|
|
2127
2401
|
var mergeConfig = function mergeConfig(config1, config2) {
|
|
2128
2402
|
// eslint-disable-next-line no-param-reassign
|
|
2129
2403
|
config2 = config2 || {};
|
|
2404
|
+
assertParamsDepth(utils.hasOwnProperty(config1, 'params') ? config1.params : undefined);
|
|
2405
|
+
assertParamsDepth(utils.hasOwnProperty(config2, 'params') ? config2.params : undefined);
|
|
2130
2406
|
// Use a null-prototype object so a polluted Object.prototype cannot leak
|
|
2131
2407
|
// values (e.g. transport, adapter) into the returned config via inheritance.
|
|
2132
2408
|
var config = Object.create(null);
|
|
@@ -2177,6 +2453,11 @@ var mergeConfig = function mergeConfig(config1, config2) {
|
|
|
2177
2453
|
}
|
|
2178
2454
|
}
|
|
2179
2455
|
|
|
2456
|
+
function defaultToConfig2Reference(prop) {
|
|
2457
|
+
var value = getOwn(config2, prop);
|
|
2458
|
+
return utils.isUndefined(value) ? getOwn(config1, prop) : value;
|
|
2459
|
+
}
|
|
2460
|
+
|
|
2180
2461
|
// eslint-disable-next-line consistent-return
|
|
2181
2462
|
function mergeDirectKeys(prop) {
|
|
2182
2463
|
if (hasOwn(config2, prop)) {
|
|
@@ -2212,6 +2493,8 @@ var mergeConfig = function mergeConfig(config1, config2) {
|
|
|
2212
2493
|
'httpAgent': defaultToConfig2,
|
|
2213
2494
|
'httpsAgent': defaultToConfig2,
|
|
2214
2495
|
'cancelToken': defaultToConfig2,
|
|
2496
|
+
// Signals are live objects; cloning them snapshots getters and reasons.
|
|
2497
|
+
'signal': defaultToConfig2Reference,
|
|
2215
2498
|
'socketPath': defaultToConfig2,
|
|
2216
2499
|
'allowedSocketPaths': defaultToConfig2,
|
|
2217
2500
|
'responseEncoding': defaultToConfig2,
|
|
@@ -2231,7 +2514,7 @@ var mergeConfig = function mergeConfig(config1, config2) {
|
|
|
2231
2514
|
};
|
|
2232
2515
|
|
|
2233
2516
|
var data = {
|
|
2234
|
-
"version": "0.
|
|
2517
|
+
"version": "0.35.0"
|
|
2235
2518
|
};
|
|
2236
2519
|
|
|
2237
2520
|
var VERSION = data.version;
|
|
@@ -2320,6 +2603,56 @@ var validator = {
|
|
|
2320
2603
|
};
|
|
2321
2604
|
|
|
2322
2605
|
var validators = validator.validators;
|
|
2606
|
+
|
|
2607
|
+
function captureCallerStack(boundary) {
|
|
2608
|
+
var caller = {};
|
|
2609
|
+
try {
|
|
2610
|
+
if (Error.captureStackTrace) {
|
|
2611
|
+
Error.captureStackTrace(caller, boundary);
|
|
2612
|
+
} else {
|
|
2613
|
+
caller = new Error();
|
|
2614
|
+
}
|
|
2615
|
+
} catch (e) {
|
|
2616
|
+
// Stack hooks must not prevent a request from being sent.
|
|
2617
|
+
}
|
|
2618
|
+
return caller;
|
|
2619
|
+
}
|
|
2620
|
+
|
|
2621
|
+
function attachCallerStack(promise, caller) {
|
|
2622
|
+
if (!caller) {
|
|
2623
|
+
return promise;
|
|
2624
|
+
}
|
|
2625
|
+
|
|
2626
|
+
return promise.then(null, function onRequestRejected(error) {
|
|
2627
|
+
try {
|
|
2628
|
+
if (error instanceof Error || Object.prototype.toString.call(error) === '[object Error]') {
|
|
2629
|
+
// Capture at dispatch time, but only format the stack on failure.
|
|
2630
|
+
// Capturing in this callback would lose callers using .then/.catch.
|
|
2631
|
+
var stack = caller.stack;
|
|
2632
|
+
if (typeof stack === 'string') {
|
|
2633
|
+
var newline = stack.indexOf('\n');
|
|
2634
|
+
stack = newline === -1 ? '' : stack.slice(newline + 1);
|
|
2635
|
+
var original = error.stack;
|
|
2636
|
+
if (stack && (original === undefined || original === null || original === '')) {
|
|
2637
|
+
error.stack = stack;
|
|
2638
|
+
} else if (stack && typeof original === 'string' && original.indexOf(stack) === -1) {
|
|
2639
|
+
error.stack = original + '\n' + stack;
|
|
2640
|
+
}
|
|
2641
|
+
}
|
|
2642
|
+
}
|
|
2643
|
+
} catch (e) {
|
|
2644
|
+
// Frozen errors and custom stack accessors must retain their rejection.
|
|
2645
|
+
}
|
|
2646
|
+
return Promise.reject(error);
|
|
2647
|
+
});
|
|
2648
|
+
}
|
|
2649
|
+
|
|
2650
|
+
function dispatchAfterRecovery(config) {
|
|
2651
|
+
return function dispatchRecoveredRequest() {
|
|
2652
|
+
return dispatchRequest(config);
|
|
2653
|
+
};
|
|
2654
|
+
}
|
|
2655
|
+
|
|
2323
2656
|
/**
|
|
2324
2657
|
* Create a new instance of Axios
|
|
2325
2658
|
*
|
|
@@ -2349,12 +2682,19 @@ Axios.prototype.request = function request(configOrUrl, config) {
|
|
|
2349
2682
|
config = configOrUrl || {};
|
|
2350
2683
|
}
|
|
2351
2684
|
|
|
2352
|
-
|
|
2685
|
+
try {
|
|
2686
|
+
config = mergeConfig(this.defaults, config);
|
|
2687
|
+
} catch (error) {
|
|
2688
|
+
return Promise.reject(error);
|
|
2689
|
+
}
|
|
2690
|
+
var caller = config.captureCallerStack === true ? captureCallerStack(request) : null;
|
|
2353
2691
|
|
|
2354
|
-
// Set config.method
|
|
2692
|
+
// Set config.method. The merged config is null-prototype, but instance
|
|
2693
|
+
// defaults may be an ordinary object, so the fallback is read as an own
|
|
2694
|
+
// property to keep an inherited value from choosing the request method.
|
|
2355
2695
|
if (config.method) {
|
|
2356
2696
|
config.method = config.method.toLowerCase();
|
|
2357
|
-
} else if (this.defaults.method) {
|
|
2697
|
+
} else if (utils.hasOwnProperty(this.defaults, 'method') && this.defaults.method) {
|
|
2358
2698
|
config.method = this.defaults.method.toLowerCase();
|
|
2359
2699
|
} else {
|
|
2360
2700
|
config.method = 'get';
|
|
@@ -2416,7 +2756,7 @@ Axios.prototype.request = function request(configOrUrl, config) {
|
|
|
2416
2756
|
promise = promise.then(chain.shift(), chain.shift());
|
|
2417
2757
|
}
|
|
2418
2758
|
|
|
2419
|
-
return promise;
|
|
2759
|
+
return attachCallerStack(promise, caller);
|
|
2420
2760
|
}
|
|
2421
2761
|
|
|
2422
2762
|
|
|
@@ -2425,24 +2765,39 @@ Axios.prototype.request = function request(configOrUrl, config) {
|
|
|
2425
2765
|
var onFulfilled = requestInterceptorChain.shift();
|
|
2426
2766
|
var onRejected = requestInterceptorChain.shift();
|
|
2427
2767
|
try {
|
|
2428
|
-
newConfig = onFulfilled(newConfig);
|
|
2768
|
+
newConfig = onFulfilled ? onFulfilled(newConfig) : newConfig;
|
|
2429
2769
|
} catch (error) {
|
|
2430
|
-
onRejected
|
|
2770
|
+
if (!onRejected) {
|
|
2771
|
+
promise = Promise.reject(error);
|
|
2772
|
+
break;
|
|
2773
|
+
}
|
|
2774
|
+
try {
|
|
2775
|
+
var recovery = onRejected(error);
|
|
2776
|
+
if (recovery && typeof recovery.then === 'function') {
|
|
2777
|
+
promise = Promise.resolve(recovery).then(dispatchAfterRecovery(newConfig));
|
|
2778
|
+
}
|
|
2779
|
+
} catch (rejectedError) {
|
|
2780
|
+
promise = Promise.reject(rejectedError);
|
|
2781
|
+
}
|
|
2431
2782
|
break;
|
|
2432
2783
|
}
|
|
2433
2784
|
}
|
|
2434
2785
|
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2786
|
+
if (!promise) {
|
|
2787
|
+
try {
|
|
2788
|
+
promise = dispatchRequest(newConfig);
|
|
2789
|
+
} catch (error) {
|
|
2790
|
+
// Dispatch errors, including pre-aborted signals, still go through the
|
|
2791
|
+
// response interceptors registered below.
|
|
2792
|
+
promise = Promise.reject(error);
|
|
2793
|
+
}
|
|
2439
2794
|
}
|
|
2440
2795
|
|
|
2441
2796
|
while (responseInterceptorChain.length) {
|
|
2442
2797
|
promise = promise.then(responseInterceptorChain.shift(), responseInterceptorChain.shift());
|
|
2443
2798
|
}
|
|
2444
2799
|
|
|
2445
|
-
return promise;
|
|
2800
|
+
return attachCallerStack(promise, caller);
|
|
2446
2801
|
};
|
|
2447
2802
|
|
|
2448
2803
|
Axios.prototype.getUri = function getUri(config) {
|
|
@@ -2457,11 +2812,16 @@ utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData
|
|
|
2457
2812
|
Axios.prototype[method] = function(url, config) {
|
|
2458
2813
|
var requestConfig = config || {};
|
|
2459
2814
|
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2815
|
+
try {
|
|
2816
|
+
requestConfig = mergeConfig(requestConfig, {
|
|
2817
|
+
method: method,
|
|
2818
|
+
url: url,
|
|
2819
|
+
data: utils.hasOwnProperty(requestConfig, 'data') ? requestConfig.data : undefined
|
|
2820
|
+
});
|
|
2821
|
+
} catch (error) {
|
|
2822
|
+
return Promise.reject(error);
|
|
2823
|
+
}
|
|
2824
|
+
return this.request(requestConfig);
|
|
2465
2825
|
};
|
|
2466
2826
|
});
|
|
2467
2827
|
|
|
@@ -2470,14 +2830,20 @@ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
|
|
2470
2830
|
|
|
2471
2831
|
function generateHTTPMethod(isForm) {
|
|
2472
2832
|
return function httpMethod(url, data, config) {
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2833
|
+
var requestConfig;
|
|
2834
|
+
try {
|
|
2835
|
+
requestConfig = mergeConfig(config || {}, {
|
|
2836
|
+
method: method,
|
|
2837
|
+
headers: isForm ? {
|
|
2838
|
+
'Content-Type': 'multipart/form-data'
|
|
2839
|
+
} : {},
|
|
2840
|
+
url: url,
|
|
2841
|
+
data: data
|
|
2842
|
+
});
|
|
2843
|
+
} catch (error) {
|
|
2844
|
+
return Promise.reject(error);
|
|
2845
|
+
}
|
|
2846
|
+
return this.request(requestConfig);
|
|
2481
2847
|
};
|
|
2482
2848
|
}
|
|
2483
2849
|
|