axios 1.10.0 → 1.12.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 +52 -0
- package/README.md +13 -13
- package/dist/axios.js +395 -292
- package/dist/axios.js.map +1 -1
- package/dist/axios.min.js +2 -2
- package/dist/axios.min.js.map +1 -1
- package/dist/browser/axios.cjs +329 -217
- package/dist/browser/axios.cjs.map +1 -1
- package/dist/esm/axios.js +329 -217
- package/dist/esm/axios.js.map +1 -1
- package/dist/esm/axios.min.js +2 -2
- package/dist/esm/axios.min.js.map +1 -1
- package/dist/node/axios.cjs +420 -217
- package/dist/node/axios.cjs.map +1 -1
- package/index.d.cts +22 -7
- package/index.d.ts +10 -4
- package/lib/adapters/adapters.js +6 -4
- package/lib/adapters/fetch.js +220 -163
- package/lib/adapters/http.js +18 -0
- package/lib/adapters/xhr.js +11 -8
- package/lib/core/Axios.js +2 -2
- package/lib/core/AxiosError.js +10 -3
- package/lib/core/dispatchRequest.js +1 -1
- package/lib/core/mergeConfig.js +1 -1
- package/lib/defaults/index.js +1 -1
- package/lib/env/data.js +1 -1
- package/lib/helpers/buildURL.js +1 -3
- package/lib/helpers/estimateDataURLDecodedBytes.js +73 -0
- package/lib/helpers/resolveConfig.js +13 -9
- package/lib/helpers/throttle.js +1 -1
- package/lib/helpers/toURLEncodedForm.js +4 -3
- package/lib/utils.js +42 -2
- package/package.json +15 -12
package/dist/node/axios.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! Axios v1.
|
|
1
|
+
/*! Axios v1.12.0 Copyright (c) 2025 Matt Zabriskie and contributors */
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
const FormData$1 = require('form-data');
|
|
@@ -77,7 +77,7 @@ const isUndefined = typeOfTest('undefined');
|
|
|
77
77
|
*/
|
|
78
78
|
function isBuffer(val) {
|
|
79
79
|
return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
|
|
80
|
-
&& isFunction(val.constructor.isBuffer) && val.constructor.isBuffer(val);
|
|
80
|
+
&& isFunction$1(val.constructor.isBuffer) && val.constructor.isBuffer(val);
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
/**
|
|
@@ -122,7 +122,7 @@ const isString = typeOfTest('string');
|
|
|
122
122
|
* @param {*} val The value to test
|
|
123
123
|
* @returns {boolean} True if value is a Function, otherwise false
|
|
124
124
|
*/
|
|
125
|
-
const isFunction = typeOfTest('function');
|
|
125
|
+
const isFunction$1 = typeOfTest('function');
|
|
126
126
|
|
|
127
127
|
/**
|
|
128
128
|
* Determine if a value is a Number
|
|
@@ -166,6 +166,27 @@ const isPlainObject = (val) => {
|
|
|
166
166
|
return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(toStringTag in val) && !(iterator in val);
|
|
167
167
|
};
|
|
168
168
|
|
|
169
|
+
/**
|
|
170
|
+
* Determine if a value is an empty object (safely handles Buffers)
|
|
171
|
+
*
|
|
172
|
+
* @param {*} val The value to test
|
|
173
|
+
*
|
|
174
|
+
* @returns {boolean} True if value is an empty object, otherwise false
|
|
175
|
+
*/
|
|
176
|
+
const isEmptyObject = (val) => {
|
|
177
|
+
// Early return for non-objects or Buffers to prevent RangeError
|
|
178
|
+
if (!isObject(val) || isBuffer(val)) {
|
|
179
|
+
return false;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
try {
|
|
183
|
+
return Object.keys(val).length === 0 && Object.getPrototypeOf(val) === Object.prototype;
|
|
184
|
+
} catch (e) {
|
|
185
|
+
// Fallback for any other objects that might cause RangeError with Object.keys()
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
|
|
169
190
|
/**
|
|
170
191
|
* Determine if a value is a Date
|
|
171
192
|
*
|
|
@@ -209,7 +230,7 @@ const isFileList = kindOfTest('FileList');
|
|
|
209
230
|
*
|
|
210
231
|
* @returns {boolean} True if value is a Stream, otherwise false
|
|
211
232
|
*/
|
|
212
|
-
const isStream = (val) => isObject(val) && isFunction(val.pipe);
|
|
233
|
+
const isStream = (val) => isObject(val) && isFunction$1(val.pipe);
|
|
213
234
|
|
|
214
235
|
/**
|
|
215
236
|
* Determine if a value is a FormData
|
|
@@ -222,10 +243,10 @@ const isFormData = (thing) => {
|
|
|
222
243
|
let kind;
|
|
223
244
|
return thing && (
|
|
224
245
|
(typeof FormData === 'function' && thing instanceof FormData) || (
|
|
225
|
-
isFunction(thing.append) && (
|
|
246
|
+
isFunction$1(thing.append) && (
|
|
226
247
|
(kind = kindOf(thing)) === 'formdata' ||
|
|
227
248
|
// detect form-data instance
|
|
228
|
-
(kind === 'object' && isFunction(thing.toString) && thing.toString() === '[object FormData]')
|
|
249
|
+
(kind === 'object' && isFunction$1(thing.toString) && thing.toString() === '[object FormData]')
|
|
229
250
|
)
|
|
230
251
|
)
|
|
231
252
|
)
|
|
@@ -288,6 +309,11 @@ function forEach(obj, fn, {allOwnKeys = false} = {}) {
|
|
|
288
309
|
fn.call(null, obj[i], i, obj);
|
|
289
310
|
}
|
|
290
311
|
} else {
|
|
312
|
+
// Buffer check
|
|
313
|
+
if (isBuffer(obj)) {
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
|
|
291
317
|
// Iterate over object keys
|
|
292
318
|
const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
|
|
293
319
|
const len = keys.length;
|
|
@@ -301,6 +327,10 @@ function forEach(obj, fn, {allOwnKeys = false} = {}) {
|
|
|
301
327
|
}
|
|
302
328
|
|
|
303
329
|
function findKey(obj, key) {
|
|
330
|
+
if (isBuffer(obj)){
|
|
331
|
+
return null;
|
|
332
|
+
}
|
|
333
|
+
|
|
304
334
|
key = key.toLowerCase();
|
|
305
335
|
const keys = Object.keys(obj);
|
|
306
336
|
let i = keys.length;
|
|
@@ -341,7 +371,7 @@ const isContextDefined = (context) => !isUndefined(context) && context !== _glob
|
|
|
341
371
|
* @returns {Object} Result of all merge properties
|
|
342
372
|
*/
|
|
343
373
|
function merge(/* obj1, obj2, obj3, ... */) {
|
|
344
|
-
const {caseless} = isContextDefined(this) && this || {};
|
|
374
|
+
const {caseless, skipUndefined} = isContextDefined(this) && this || {};
|
|
345
375
|
const result = {};
|
|
346
376
|
const assignValue = (val, key) => {
|
|
347
377
|
const targetKey = caseless && findKey(result, key) || key;
|
|
@@ -352,7 +382,9 @@ function merge(/* obj1, obj2, obj3, ... */) {
|
|
|
352
382
|
} else if (isArray(val)) {
|
|
353
383
|
result[targetKey] = val.slice();
|
|
354
384
|
} else {
|
|
355
|
-
|
|
385
|
+
if (!skipUndefined || !isUndefined(val)) {
|
|
386
|
+
result[targetKey] = val;
|
|
387
|
+
}
|
|
356
388
|
}
|
|
357
389
|
};
|
|
358
390
|
|
|
@@ -374,7 +406,7 @@ function merge(/* obj1, obj2, obj3, ... */) {
|
|
|
374
406
|
*/
|
|
375
407
|
const extend = (a, b, thisArg, {allOwnKeys}= {}) => {
|
|
376
408
|
forEach(b, (val, key) => {
|
|
377
|
-
if (thisArg && isFunction(val)) {
|
|
409
|
+
if (thisArg && isFunction$1(val)) {
|
|
378
410
|
a[key] = bind(val, thisArg);
|
|
379
411
|
} else {
|
|
380
412
|
a[key] = val;
|
|
@@ -590,13 +622,13 @@ const reduceDescriptors = (obj, reducer) => {
|
|
|
590
622
|
const freezeMethods = (obj) => {
|
|
591
623
|
reduceDescriptors(obj, (descriptor, name) => {
|
|
592
624
|
// skip restricted props in strict mode
|
|
593
|
-
if (isFunction(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
|
|
625
|
+
if (isFunction$1(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
|
|
594
626
|
return false;
|
|
595
627
|
}
|
|
596
628
|
|
|
597
629
|
const value = obj[name];
|
|
598
630
|
|
|
599
|
-
if (!isFunction(value)) return;
|
|
631
|
+
if (!isFunction$1(value)) return;
|
|
600
632
|
|
|
601
633
|
descriptor.enumerable = false;
|
|
602
634
|
|
|
@@ -633,6 +665,8 @@ const toFiniteNumber = (value, defaultValue) => {
|
|
|
633
665
|
return value != null && Number.isFinite(value = +value) ? value : defaultValue;
|
|
634
666
|
};
|
|
635
667
|
|
|
668
|
+
|
|
669
|
+
|
|
636
670
|
/**
|
|
637
671
|
* If the thing is a FormData object, return true, otherwise return false.
|
|
638
672
|
*
|
|
@@ -641,7 +675,7 @@ const toFiniteNumber = (value, defaultValue) => {
|
|
|
641
675
|
* @returns {boolean}
|
|
642
676
|
*/
|
|
643
677
|
function isSpecCompliantForm(thing) {
|
|
644
|
-
return !!(thing && isFunction(thing.append) && thing[toStringTag] === 'FormData' && thing[iterator]);
|
|
678
|
+
return !!(thing && isFunction$1(thing.append) && thing[toStringTag] === 'FormData' && thing[iterator]);
|
|
645
679
|
}
|
|
646
680
|
|
|
647
681
|
const toJSONObject = (obj) => {
|
|
@@ -654,6 +688,11 @@ const toJSONObject = (obj) => {
|
|
|
654
688
|
return;
|
|
655
689
|
}
|
|
656
690
|
|
|
691
|
+
//Buffer check
|
|
692
|
+
if (isBuffer(source)) {
|
|
693
|
+
return source;
|
|
694
|
+
}
|
|
695
|
+
|
|
657
696
|
if(!('toJSON' in source)) {
|
|
658
697
|
stack[i] = source;
|
|
659
698
|
const target = isArray(source) ? [] : {};
|
|
@@ -678,7 +717,7 @@ const toJSONObject = (obj) => {
|
|
|
678
717
|
const isAsyncFn = kindOfTest('AsyncFunction');
|
|
679
718
|
|
|
680
719
|
const isThenable = (thing) =>
|
|
681
|
-
thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);
|
|
720
|
+
thing && (isObject(thing) || isFunction$1(thing)) && isFunction$1(thing.then) && isFunction$1(thing.catch);
|
|
682
721
|
|
|
683
722
|
// original code
|
|
684
723
|
// https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
|
|
@@ -702,7 +741,7 @@ const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
|
|
|
702
741
|
})(`axios@${Math.random()}`, []) : (cb) => setTimeout(cb);
|
|
703
742
|
})(
|
|
704
743
|
typeof setImmediate === 'function',
|
|
705
|
-
isFunction(_global.postMessage)
|
|
744
|
+
isFunction$1(_global.postMessage)
|
|
706
745
|
);
|
|
707
746
|
|
|
708
747
|
const asap = typeof queueMicrotask !== 'undefined' ?
|
|
@@ -711,7 +750,7 @@ const asap = typeof queueMicrotask !== 'undefined' ?
|
|
|
711
750
|
// *********************
|
|
712
751
|
|
|
713
752
|
|
|
714
|
-
const isIterable = (thing) => thing != null && isFunction(thing[iterator]);
|
|
753
|
+
const isIterable = (thing) => thing != null && isFunction$1(thing[iterator]);
|
|
715
754
|
|
|
716
755
|
|
|
717
756
|
const utils$1 = {
|
|
@@ -725,6 +764,7 @@ const utils$1 = {
|
|
|
725
764
|
isBoolean,
|
|
726
765
|
isObject,
|
|
727
766
|
isPlainObject,
|
|
767
|
+
isEmptyObject,
|
|
728
768
|
isReadableStream,
|
|
729
769
|
isRequest,
|
|
730
770
|
isResponse,
|
|
@@ -734,7 +774,7 @@ const utils$1 = {
|
|
|
734
774
|
isFile,
|
|
735
775
|
isBlob,
|
|
736
776
|
isRegExp,
|
|
737
|
-
isFunction,
|
|
777
|
+
isFunction: isFunction$1,
|
|
738
778
|
isStream,
|
|
739
779
|
isURLSearchParams,
|
|
740
780
|
isTypedArray,
|
|
@@ -860,11 +900,18 @@ AxiosError.from = (error, code, config, request, response, customProps) => {
|
|
|
860
900
|
return prop !== 'isAxiosError';
|
|
861
901
|
});
|
|
862
902
|
|
|
863
|
-
|
|
903
|
+
const msg = error && error.message ? error.message : 'Error';
|
|
864
904
|
|
|
865
|
-
|
|
905
|
+
// Prefer explicit code; otherwise copy the low-level error's code (e.g. ECONNREFUSED)
|
|
906
|
+
const errCode = code == null && error ? error.code : code;
|
|
907
|
+
AxiosError.call(axiosError, msg, errCode, config, request, response);
|
|
866
908
|
|
|
867
|
-
|
|
909
|
+
// Chain the original error on the standard field; non-enumerable to avoid JSON noise
|
|
910
|
+
if (error && axiosError.cause == null) {
|
|
911
|
+
Object.defineProperty(axiosError, 'cause', { value: error, configurable: true });
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
axiosError.name = (error && error.name) || 'Error';
|
|
868
915
|
|
|
869
916
|
customProps && Object.assign(axiosError, customProps);
|
|
870
917
|
|
|
@@ -1152,9 +1199,7 @@ function encode(val) {
|
|
|
1152
1199
|
replace(/%3A/gi, ':').
|
|
1153
1200
|
replace(/%24/g, '$').
|
|
1154
1201
|
replace(/%2C/gi, ',').
|
|
1155
|
-
replace(/%20/g, '+')
|
|
1156
|
-
replace(/%5B/gi, '[').
|
|
1157
|
-
replace(/%5D/gi, ']');
|
|
1202
|
+
replace(/%20/g, '+');
|
|
1158
1203
|
}
|
|
1159
1204
|
|
|
1160
1205
|
/**
|
|
@@ -1374,7 +1419,7 @@ const platform = {
|
|
|
1374
1419
|
};
|
|
1375
1420
|
|
|
1376
1421
|
function toURLEncodedForm(data, options) {
|
|
1377
|
-
return toFormData(data, new platform.classes.URLSearchParams(),
|
|
1422
|
+
return toFormData(data, new platform.classes.URLSearchParams(), {
|
|
1378
1423
|
visitor: function(value, key, path, helpers) {
|
|
1379
1424
|
if (platform.isNode && utils$1.isBuffer(value)) {
|
|
1380
1425
|
this.append(key, value.toString('base64'));
|
|
@@ -1382,8 +1427,9 @@ function toURLEncodedForm(data, options) {
|
|
|
1382
1427
|
}
|
|
1383
1428
|
|
|
1384
1429
|
return helpers.defaultVisitor.apply(this, arguments);
|
|
1385
|
-
}
|
|
1386
|
-
|
|
1430
|
+
},
|
|
1431
|
+
...options
|
|
1432
|
+
});
|
|
1387
1433
|
}
|
|
1388
1434
|
|
|
1389
1435
|
/**
|
|
@@ -1579,7 +1625,7 @@ const defaults = {
|
|
|
1579
1625
|
const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
|
1580
1626
|
|
|
1581
1627
|
try {
|
|
1582
|
-
return JSON.parse(data);
|
|
1628
|
+
return JSON.parse(data, this.parseReviver);
|
|
1583
1629
|
} catch (e) {
|
|
1584
1630
|
if (strictJSONParsing) {
|
|
1585
1631
|
if (e.name === 'SyntaxError') {
|
|
@@ -2106,7 +2152,7 @@ function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
|
|
|
2106
2152
|
return requestedURL;
|
|
2107
2153
|
}
|
|
2108
2154
|
|
|
2109
|
-
const VERSION = "1.
|
|
2155
|
+
const VERSION = "1.12.0";
|
|
2110
2156
|
|
|
2111
2157
|
function parseProtocol(url) {
|
|
2112
2158
|
const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
|
|
@@ -2534,7 +2580,7 @@ function throttle(fn, freq) {
|
|
|
2534
2580
|
clearTimeout(timer);
|
|
2535
2581
|
timer = null;
|
|
2536
2582
|
}
|
|
2537
|
-
fn
|
|
2583
|
+
fn(...args);
|
|
2538
2584
|
};
|
|
2539
2585
|
|
|
2540
2586
|
const throttled = (...args) => {
|
|
@@ -2599,6 +2645,80 @@ const progressEventDecorator = (total, throttled) => {
|
|
|
2599
2645
|
|
|
2600
2646
|
const asyncDecorator = (fn) => (...args) => utils$1.asap(() => fn(...args));
|
|
2601
2647
|
|
|
2648
|
+
/**
|
|
2649
|
+
* Estimate decoded byte length of a data:// URL *without* allocating large buffers.
|
|
2650
|
+
* - For base64: compute exact decoded size using length and padding;
|
|
2651
|
+
* handle %XX at the character-count level (no string allocation).
|
|
2652
|
+
* - For non-base64: use UTF-8 byteLength of the encoded body as a safe upper bound.
|
|
2653
|
+
*
|
|
2654
|
+
* @param {string} url
|
|
2655
|
+
* @returns {number}
|
|
2656
|
+
*/
|
|
2657
|
+
function estimateDataURLDecodedBytes(url) {
|
|
2658
|
+
if (!url || typeof url !== 'string') return 0;
|
|
2659
|
+
if (!url.startsWith('data:')) return 0;
|
|
2660
|
+
|
|
2661
|
+
const comma = url.indexOf(',');
|
|
2662
|
+
if (comma < 0) return 0;
|
|
2663
|
+
|
|
2664
|
+
const meta = url.slice(5, comma);
|
|
2665
|
+
const body = url.slice(comma + 1);
|
|
2666
|
+
const isBase64 = /;base64/i.test(meta);
|
|
2667
|
+
|
|
2668
|
+
if (isBase64) {
|
|
2669
|
+
let effectiveLen = body.length;
|
|
2670
|
+
const len = body.length; // cache length
|
|
2671
|
+
|
|
2672
|
+
for (let i = 0; i < len; i++) {
|
|
2673
|
+
if (body.charCodeAt(i) === 37 /* '%' */ && i + 2 < len) {
|
|
2674
|
+
const a = body.charCodeAt(i + 1);
|
|
2675
|
+
const b = body.charCodeAt(i + 2);
|
|
2676
|
+
const isHex =
|
|
2677
|
+
((a >= 48 && a <= 57) || (a >= 65 && a <= 70) || (a >= 97 && a <= 102)) &&
|
|
2678
|
+
((b >= 48 && b <= 57) || (b >= 65 && b <= 70) || (b >= 97 && b <= 102));
|
|
2679
|
+
|
|
2680
|
+
if (isHex) {
|
|
2681
|
+
effectiveLen -= 2;
|
|
2682
|
+
i += 2;
|
|
2683
|
+
}
|
|
2684
|
+
}
|
|
2685
|
+
}
|
|
2686
|
+
|
|
2687
|
+
let pad = 0;
|
|
2688
|
+
let idx = len - 1;
|
|
2689
|
+
|
|
2690
|
+
const tailIsPct3D = (j) =>
|
|
2691
|
+
j >= 2 &&
|
|
2692
|
+
body.charCodeAt(j - 2) === 37 && // '%'
|
|
2693
|
+
body.charCodeAt(j - 1) === 51 && // '3'
|
|
2694
|
+
(body.charCodeAt(j) === 68 || body.charCodeAt(j) === 100); // 'D' or 'd'
|
|
2695
|
+
|
|
2696
|
+
if (idx >= 0) {
|
|
2697
|
+
if (body.charCodeAt(idx) === 61 /* '=' */) {
|
|
2698
|
+
pad++;
|
|
2699
|
+
idx--;
|
|
2700
|
+
} else if (tailIsPct3D(idx)) {
|
|
2701
|
+
pad++;
|
|
2702
|
+
idx -= 3;
|
|
2703
|
+
}
|
|
2704
|
+
}
|
|
2705
|
+
|
|
2706
|
+
if (pad === 1 && idx >= 0) {
|
|
2707
|
+
if (body.charCodeAt(idx) === 61 /* '=' */) {
|
|
2708
|
+
pad++;
|
|
2709
|
+
} else if (tailIsPct3D(idx)) {
|
|
2710
|
+
pad++;
|
|
2711
|
+
}
|
|
2712
|
+
}
|
|
2713
|
+
|
|
2714
|
+
const groups = Math.floor(effectiveLen / 4);
|
|
2715
|
+
const bytes = groups * 3 - (pad || 0);
|
|
2716
|
+
return bytes > 0 ? bytes : 0;
|
|
2717
|
+
}
|
|
2718
|
+
|
|
2719
|
+
return Buffer.byteLength(body, 'utf8');
|
|
2720
|
+
}
|
|
2721
|
+
|
|
2602
2722
|
const zlibOptions = {
|
|
2603
2723
|
flush: zlib__default["default"].constants.Z_SYNC_FLUSH,
|
|
2604
2724
|
finishFlush: zlib__default["default"].constants.Z_SYNC_FLUSH
|
|
@@ -2619,6 +2739,7 @@ const supportedProtocols = platform.protocols.map(protocol => {
|
|
|
2619
2739
|
return protocol + ':';
|
|
2620
2740
|
});
|
|
2621
2741
|
|
|
2742
|
+
|
|
2622
2743
|
const flushOnFinish = (stream, [throttled, flush]) => {
|
|
2623
2744
|
stream
|
|
2624
2745
|
.on('end', flush)
|
|
@@ -2627,6 +2748,7 @@ const flushOnFinish = (stream, [throttled, flush]) => {
|
|
|
2627
2748
|
return throttled;
|
|
2628
2749
|
};
|
|
2629
2750
|
|
|
2751
|
+
|
|
2630
2752
|
/**
|
|
2631
2753
|
* If the proxy or config beforeRedirects functions are defined, call them with the options
|
|
2632
2754
|
* object.
|
|
@@ -2806,6 +2928,21 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
2806
2928
|
const protocol = parsed.protocol || supportedProtocols[0];
|
|
2807
2929
|
|
|
2808
2930
|
if (protocol === 'data:') {
|
|
2931
|
+
// Apply the same semantics as HTTP: only enforce if a finite, non-negative cap is set.
|
|
2932
|
+
if (config.maxContentLength > -1) {
|
|
2933
|
+
// Use the exact string passed to fromDataURI (config.url); fall back to fullPath if needed.
|
|
2934
|
+
const dataUrl = String(config.url || fullPath || '');
|
|
2935
|
+
const estimated = estimateDataURLDecodedBytes(dataUrl);
|
|
2936
|
+
|
|
2937
|
+
if (estimated > config.maxContentLength) {
|
|
2938
|
+
return reject(new AxiosError(
|
|
2939
|
+
'maxContentLength size of ' + config.maxContentLength + ' exceeded',
|
|
2940
|
+
AxiosError.ERR_BAD_RESPONSE,
|
|
2941
|
+
config
|
|
2942
|
+
));
|
|
2943
|
+
}
|
|
2944
|
+
}
|
|
2945
|
+
|
|
2809
2946
|
let convertedData;
|
|
2810
2947
|
|
|
2811
2948
|
if (method !== 'GET') {
|
|
@@ -3408,7 +3545,7 @@ function mergeConfig(config1, config2) {
|
|
|
3408
3545
|
headers: (a, b , prop) => mergeDeepProperties(headersToObject(a), headersToObject(b),prop, true)
|
|
3409
3546
|
};
|
|
3410
3547
|
|
|
3411
|
-
utils$1.forEach(Object.keys(
|
|
3548
|
+
utils$1.forEach(Object.keys({...config1, ...config2}), function computeConfigValue(prop) {
|
|
3412
3549
|
const merge = mergeMap[prop] || mergeDeepProperties;
|
|
3413
3550
|
const configValue = merge(config1[prop], config2[prop], prop);
|
|
3414
3551
|
(utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
|
|
@@ -3420,7 +3557,7 @@ function mergeConfig(config1, config2) {
|
|
|
3420
3557
|
const resolveConfig = (config) => {
|
|
3421
3558
|
const newConfig = mergeConfig({}, config);
|
|
3422
3559
|
|
|
3423
|
-
let {data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth} = newConfig;
|
|
3560
|
+
let { data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth } = newConfig;
|
|
3424
3561
|
|
|
3425
3562
|
newConfig.headers = headers = AxiosHeaders$1.from(headers);
|
|
3426
3563
|
|
|
@@ -3433,17 +3570,21 @@ const resolveConfig = (config) => {
|
|
|
3433
3570
|
);
|
|
3434
3571
|
}
|
|
3435
3572
|
|
|
3436
|
-
let contentType;
|
|
3437
|
-
|
|
3438
3573
|
if (utils$1.isFormData(data)) {
|
|
3439
3574
|
if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
|
|
3440
|
-
headers.setContentType(undefined); //
|
|
3441
|
-
} else if ((
|
|
3442
|
-
//
|
|
3443
|
-
const
|
|
3444
|
-
headers
|
|
3575
|
+
headers.setContentType(undefined); // browser handles it
|
|
3576
|
+
} else if (utils$1.isFunction(data.getHeaders)) {
|
|
3577
|
+
// Node.js FormData (like form-data package)
|
|
3578
|
+
const formHeaders = data.getHeaders();
|
|
3579
|
+
// Only set safe headers to avoid overwriting security headers
|
|
3580
|
+
const allowedHeaders = ['content-type', 'content-length'];
|
|
3581
|
+
Object.entries(formHeaders).forEach(([key, val]) => {
|
|
3582
|
+
if (allowedHeaders.includes(key.toLowerCase())) {
|
|
3583
|
+
headers.set(key, val);
|
|
3584
|
+
}
|
|
3585
|
+
});
|
|
3445
3586
|
}
|
|
3446
|
-
}
|
|
3587
|
+
}
|
|
3447
3588
|
|
|
3448
3589
|
// Add xsrf header
|
|
3449
3590
|
// This is only done if running in a standard browser environment.
|
|
@@ -3560,15 +3701,18 @@ const xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
3560
3701
|
};
|
|
3561
3702
|
|
|
3562
3703
|
// Handle low level network errors
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3704
|
+
request.onerror = function handleError(event) {
|
|
3705
|
+
// Browsers deliver a ProgressEvent in XHR onerror
|
|
3706
|
+
// (message may be empty; when present, surface it)
|
|
3707
|
+
// See https://developer.mozilla.org/docs/Web/API/XMLHttpRequest/error_event
|
|
3708
|
+
const msg = event && event.message ? event.message : 'Network Error';
|
|
3709
|
+
const err = new AxiosError(msg, AxiosError.ERR_NETWORK, config, request);
|
|
3710
|
+
// attach the underlying event for consumers who want details
|
|
3711
|
+
err.event = event || null;
|
|
3712
|
+
reject(err);
|
|
3713
|
+
request = null;
|
|
3570
3714
|
};
|
|
3571
|
-
|
|
3715
|
+
|
|
3572
3716
|
// Handle timeout
|
|
3573
3717
|
request.ontimeout = function handleTimeout() {
|
|
3574
3718
|
let timeoutErrorMessage = _config.timeout ? 'timeout of ' + _config.timeout + 'ms exceeded' : 'timeout exceeded';
|
|
@@ -3784,14 +3928,18 @@ const trackStream = (stream, chunkSize, onProgress, onFinish) => {
|
|
|
3784
3928
|
})
|
|
3785
3929
|
};
|
|
3786
3930
|
|
|
3787
|
-
const
|
|
3788
|
-
|
|
3931
|
+
const DEFAULT_CHUNK_SIZE = 64 * 1024;
|
|
3932
|
+
|
|
3933
|
+
const {isFunction} = utils$1;
|
|
3934
|
+
|
|
3935
|
+
const globalFetchAPI = (({fetch, Request, Response}) => ({
|
|
3936
|
+
fetch, Request, Response
|
|
3937
|
+
}))(utils$1.global);
|
|
3938
|
+
|
|
3939
|
+
const {
|
|
3940
|
+
ReadableStream: ReadableStream$1, TextEncoder: TextEncoder$1
|
|
3941
|
+
} = utils$1.global;
|
|
3789
3942
|
|
|
3790
|
-
// used only inside the fetch adapter
|
|
3791
|
-
const encodeText = isFetchSupported && (typeof TextEncoder === 'function' ?
|
|
3792
|
-
((encoder) => (str) => encoder.encode(str))(new TextEncoder()) :
|
|
3793
|
-
async (str) => new Uint8Array(await new Response(str).arrayBuffer())
|
|
3794
|
-
);
|
|
3795
3943
|
|
|
3796
3944
|
const test = (fn, ...args) => {
|
|
3797
3945
|
try {
|
|
@@ -3801,211 +3949,266 @@ const test = (fn, ...args) => {
|
|
|
3801
3949
|
}
|
|
3802
3950
|
};
|
|
3803
3951
|
|
|
3804
|
-
const
|
|
3805
|
-
|
|
3952
|
+
const factory = (env) => {
|
|
3953
|
+
const {fetch, Request, Response} = Object.assign({}, globalFetchAPI, env);
|
|
3954
|
+
const isFetchSupported = isFunction(fetch);
|
|
3955
|
+
const isRequestSupported = isFunction(Request);
|
|
3956
|
+
const isResponseSupported = isFunction(Response);
|
|
3806
3957
|
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
get duplex() {
|
|
3811
|
-
duplexAccessed = true;
|
|
3812
|
-
return 'half';
|
|
3813
|
-
},
|
|
3814
|
-
}).headers.has('Content-Type');
|
|
3958
|
+
if (!isFetchSupported) {
|
|
3959
|
+
return false;
|
|
3960
|
+
}
|
|
3815
3961
|
|
|
3816
|
-
|
|
3817
|
-
});
|
|
3962
|
+
const isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream$1);
|
|
3818
3963
|
|
|
3819
|
-
const
|
|
3964
|
+
const encodeText = isFetchSupported && (typeof TextEncoder$1 === 'function' ?
|
|
3965
|
+
((encoder) => (str) => encoder.encode(str))(new TextEncoder$1()) :
|
|
3966
|
+
async (str) => new Uint8Array(await new Request(str).arrayBuffer())
|
|
3967
|
+
);
|
|
3820
3968
|
|
|
3821
|
-
const
|
|
3822
|
-
|
|
3969
|
+
const supportsRequestStream = isRequestSupported && isReadableStreamSupported && test(() => {
|
|
3970
|
+
let duplexAccessed = false;
|
|
3823
3971
|
|
|
3972
|
+
const hasContentType = new Request(platform.origin, {
|
|
3973
|
+
body: new ReadableStream$1(),
|
|
3974
|
+
method: 'POST',
|
|
3975
|
+
get duplex() {
|
|
3976
|
+
duplexAccessed = true;
|
|
3977
|
+
return 'half';
|
|
3978
|
+
},
|
|
3979
|
+
}).headers.has('Content-Type');
|
|
3824
3980
|
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3981
|
+
return duplexAccessed && !hasContentType;
|
|
3982
|
+
});
|
|
3983
|
+
|
|
3984
|
+
const supportsResponseStream = isResponseSupported && isReadableStreamSupported &&
|
|
3985
|
+
test(() => utils$1.isReadableStream(new Response('').body));
|
|
3986
|
+
|
|
3987
|
+
const resolvers = {
|
|
3988
|
+
stream: supportsResponseStream && ((res) => res.body)
|
|
3989
|
+
};
|
|
3990
|
+
|
|
3991
|
+
isFetchSupported && ((() => {
|
|
3992
|
+
['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(type => {
|
|
3993
|
+
!resolvers[type] && (resolvers[type] = (res, config) => {
|
|
3994
|
+
let method = res && res[type];
|
|
3995
|
+
|
|
3996
|
+
if (method) {
|
|
3997
|
+
return method.call(res);
|
|
3998
|
+
}
|
|
3828
3999
|
|
|
3829
|
-
isFetchSupported && (((res) => {
|
|
3830
|
-
['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(type => {
|
|
3831
|
-
!resolvers[type] && (resolvers[type] = utils$1.isFunction(res[type]) ? (res) => res[type]() :
|
|
3832
|
-
(_, config) => {
|
|
3833
4000
|
throw new AxiosError(`Response type '${type}' is not supported`, AxiosError.ERR_NOT_SUPPORT, config);
|
|
3834
4001
|
});
|
|
3835
|
-
|
|
3836
|
-
})(
|
|
4002
|
+
});
|
|
4003
|
+
})());
|
|
3837
4004
|
|
|
3838
|
-
const getBodyLength = async (body) => {
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
4005
|
+
const getBodyLength = async (body) => {
|
|
4006
|
+
if (body == null) {
|
|
4007
|
+
return 0;
|
|
4008
|
+
}
|
|
3842
4009
|
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
4010
|
+
if (utils$1.isBlob(body)) {
|
|
4011
|
+
return body.size;
|
|
4012
|
+
}
|
|
3846
4013
|
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
4014
|
+
if (utils$1.isSpecCompliantForm(body)) {
|
|
4015
|
+
const _request = new Request(platform.origin, {
|
|
4016
|
+
method: 'POST',
|
|
4017
|
+
body,
|
|
4018
|
+
});
|
|
4019
|
+
return (await _request.arrayBuffer()).byteLength;
|
|
4020
|
+
}
|
|
3854
4021
|
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
4022
|
+
if (utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
|
|
4023
|
+
return body.byteLength;
|
|
4024
|
+
}
|
|
3858
4025
|
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
4026
|
+
if (utils$1.isURLSearchParams(body)) {
|
|
4027
|
+
body = body + '';
|
|
4028
|
+
}
|
|
3862
4029
|
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
};
|
|
4030
|
+
if (utils$1.isString(body)) {
|
|
4031
|
+
return (await encodeText(body)).byteLength;
|
|
4032
|
+
}
|
|
4033
|
+
};
|
|
3867
4034
|
|
|
3868
|
-
const resolveBodyLength = async (headers, body) => {
|
|
3869
|
-
|
|
4035
|
+
const resolveBodyLength = async (headers, body) => {
|
|
4036
|
+
const length = utils$1.toFiniteNumber(headers.getContentLength());
|
|
3870
4037
|
|
|
3871
|
-
|
|
3872
|
-
};
|
|
4038
|
+
return length == null ? getBodyLength(body) : length;
|
|
4039
|
+
};
|
|
4040
|
+
|
|
4041
|
+
return async (config) => {
|
|
4042
|
+
let {
|
|
4043
|
+
url,
|
|
4044
|
+
method,
|
|
4045
|
+
data,
|
|
4046
|
+
signal,
|
|
4047
|
+
cancelToken,
|
|
4048
|
+
timeout,
|
|
4049
|
+
onDownloadProgress,
|
|
4050
|
+
onUploadProgress,
|
|
4051
|
+
responseType,
|
|
4052
|
+
headers,
|
|
4053
|
+
withCredentials = 'same-origin',
|
|
4054
|
+
fetchOptions
|
|
4055
|
+
} = resolveConfig(config);
|
|
4056
|
+
|
|
4057
|
+
responseType = responseType ? (responseType + '').toLowerCase() : 'text';
|
|
4058
|
+
|
|
4059
|
+
let composedSignal = composeSignals$1([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
|
|
3873
4060
|
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
method,
|
|
3878
|
-
data,
|
|
3879
|
-
signal,
|
|
3880
|
-
cancelToken,
|
|
3881
|
-
timeout,
|
|
3882
|
-
onDownloadProgress,
|
|
3883
|
-
onUploadProgress,
|
|
3884
|
-
responseType,
|
|
3885
|
-
headers,
|
|
3886
|
-
withCredentials = 'same-origin',
|
|
3887
|
-
fetchOptions
|
|
3888
|
-
} = resolveConfig(config);
|
|
3889
|
-
|
|
3890
|
-
responseType = responseType ? (responseType + '').toLowerCase() : 'text';
|
|
3891
|
-
|
|
3892
|
-
let composedSignal = composeSignals$1([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
|
|
3893
|
-
|
|
3894
|
-
let request;
|
|
3895
|
-
|
|
3896
|
-
const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
|
|
4061
|
+
let request = null;
|
|
4062
|
+
|
|
4063
|
+
const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
|
|
3897
4064
|
composedSignal.unsubscribe();
|
|
3898
|
-
|
|
4065
|
+
});
|
|
3899
4066
|
|
|
3900
|
-
|
|
4067
|
+
let requestContentLength;
|
|
3901
4068
|
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
4069
|
+
try {
|
|
4070
|
+
if (
|
|
4071
|
+
onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head' &&
|
|
4072
|
+
(requestContentLength = await resolveBodyLength(headers, data)) !== 0
|
|
4073
|
+
) {
|
|
4074
|
+
let _request = new Request(url, {
|
|
4075
|
+
method: 'POST',
|
|
4076
|
+
body: data,
|
|
4077
|
+
duplex: "half"
|
|
4078
|
+
});
|
|
3912
4079
|
|
|
3913
|
-
|
|
4080
|
+
let contentTypeHeader;
|
|
3914
4081
|
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
4082
|
+
if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
|
|
4083
|
+
headers.setContentType(contentTypeHeader);
|
|
4084
|
+
}
|
|
3918
4085
|
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
4086
|
+
if (_request.body) {
|
|
4087
|
+
const [onProgress, flush] = progressEventDecorator(
|
|
4088
|
+
requestContentLength,
|
|
4089
|
+
progressEventReducer(asyncDecorator(onUploadProgress))
|
|
4090
|
+
);
|
|
4091
|
+
|
|
4092
|
+
data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
|
|
4093
|
+
}
|
|
4094
|
+
}
|
|
3924
4095
|
|
|
3925
|
-
|
|
4096
|
+
if (!utils$1.isString(withCredentials)) {
|
|
4097
|
+
withCredentials = withCredentials ? 'include' : 'omit';
|
|
3926
4098
|
}
|
|
3927
|
-
}
|
|
3928
4099
|
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
4100
|
+
// Cloudflare Workers throws when credentials are defined
|
|
4101
|
+
// see https://github.com/cloudflare/workerd/issues/902
|
|
4102
|
+
const isCredentialsSupported = isRequestSupported && "credentials" in Request.prototype;
|
|
3932
4103
|
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
duplex: "half",
|
|
3943
|
-
credentials: isCredentialsSupported ? withCredentials : undefined
|
|
3944
|
-
});
|
|
4104
|
+
const resolvedOptions = {
|
|
4105
|
+
...fetchOptions,
|
|
4106
|
+
signal: composedSignal,
|
|
4107
|
+
method: method.toUpperCase(),
|
|
4108
|
+
headers: headers.normalize().toJSON(),
|
|
4109
|
+
body: data,
|
|
4110
|
+
duplex: "half",
|
|
4111
|
+
credentials: isCredentialsSupported ? withCredentials : undefined
|
|
4112
|
+
};
|
|
3945
4113
|
|
|
3946
|
-
|
|
4114
|
+
request = isRequestSupported && new Request(url, resolvedOptions);
|
|
3947
4115
|
|
|
3948
|
-
|
|
4116
|
+
let response = await (isRequestSupported ? fetch(request, fetchOptions) : fetch(url, resolvedOptions));
|
|
3949
4117
|
|
|
3950
|
-
|
|
3951
|
-
const options = {};
|
|
4118
|
+
const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
|
|
3952
4119
|
|
|
3953
|
-
|
|
3954
|
-
options
|
|
3955
|
-
});
|
|
4120
|
+
if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) {
|
|
4121
|
+
const options = {};
|
|
3956
4122
|
|
|
3957
|
-
|
|
4123
|
+
['status', 'statusText', 'headers'].forEach(prop => {
|
|
4124
|
+
options[prop] = response[prop];
|
|
4125
|
+
});
|
|
3958
4126
|
|
|
3959
|
-
|
|
3960
|
-
responseContentLength,
|
|
3961
|
-
progressEventReducer(asyncDecorator(onDownloadProgress), true)
|
|
3962
|
-
) || [];
|
|
4127
|
+
const responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
|
|
3963
4128
|
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
}),
|
|
3969
|
-
options
|
|
3970
|
-
);
|
|
3971
|
-
}
|
|
4129
|
+
const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
|
|
4130
|
+
responseContentLength,
|
|
4131
|
+
progressEventReducer(asyncDecorator(onDownloadProgress), true)
|
|
4132
|
+
) || [];
|
|
3972
4133
|
|
|
3973
|
-
|
|
4134
|
+
response = new Response(
|
|
4135
|
+
trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
|
|
4136
|
+
flush && flush();
|
|
4137
|
+
unsubscribe && unsubscribe();
|
|
4138
|
+
}),
|
|
4139
|
+
options
|
|
4140
|
+
);
|
|
4141
|
+
}
|
|
3974
4142
|
|
|
3975
|
-
|
|
4143
|
+
responseType = responseType || 'text';
|
|
3976
4144
|
|
|
3977
|
-
|
|
4145
|
+
let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
|
|
3978
4146
|
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
|
|
4147
|
+
!isStreamResponse && unsubscribe && unsubscribe();
|
|
4148
|
+
|
|
4149
|
+
return await new Promise((resolve, reject) => {
|
|
4150
|
+
settle(resolve, reject, {
|
|
4151
|
+
data: responseData,
|
|
4152
|
+
headers: AxiosHeaders$1.from(response.headers),
|
|
4153
|
+
status: response.status,
|
|
4154
|
+
statusText: response.statusText,
|
|
4155
|
+
config,
|
|
4156
|
+
request
|
|
4157
|
+
});
|
|
4158
|
+
})
|
|
4159
|
+
} catch (err) {
|
|
4160
|
+
unsubscribe && unsubscribe();
|
|
4161
|
+
|
|
4162
|
+
if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
|
|
4163
|
+
throw Object.assign(
|
|
4164
|
+
new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request),
|
|
4165
|
+
{
|
|
4166
|
+
cause: err.cause || err
|
|
4167
|
+
}
|
|
4168
|
+
)
|
|
4169
|
+
}
|
|
4170
|
+
|
|
4171
|
+
throw AxiosError.from(err, err && err.code, config, request);
|
|
3999
4172
|
}
|
|
4173
|
+
}
|
|
4174
|
+
};
|
|
4175
|
+
|
|
4176
|
+
const seedCache = new Map();
|
|
4177
|
+
|
|
4178
|
+
const getFetch = (config) => {
|
|
4179
|
+
let env = utils$1.merge.call({
|
|
4180
|
+
skipUndefined: true
|
|
4181
|
+
}, globalFetchAPI, config ? config.env : null);
|
|
4000
4182
|
|
|
4001
|
-
|
|
4183
|
+
const {fetch, Request, Response} = env;
|
|
4184
|
+
|
|
4185
|
+
const seeds = [
|
|
4186
|
+
Request, Response, fetch
|
|
4187
|
+
];
|
|
4188
|
+
|
|
4189
|
+
let len = seeds.length, i = len,
|
|
4190
|
+
seed, target, map = seedCache;
|
|
4191
|
+
|
|
4192
|
+
while (i--) {
|
|
4193
|
+
seed = seeds[i];
|
|
4194
|
+
target = map.get(seed);
|
|
4195
|
+
|
|
4196
|
+
target === undefined && map.set(seed, target = (i ? new Map() : factory(env)));
|
|
4197
|
+
|
|
4198
|
+
map = target;
|
|
4002
4199
|
}
|
|
4003
|
-
|
|
4200
|
+
|
|
4201
|
+
return target;
|
|
4202
|
+
};
|
|
4203
|
+
|
|
4204
|
+
getFetch();
|
|
4004
4205
|
|
|
4005
4206
|
const knownAdapters = {
|
|
4006
4207
|
http: httpAdapter,
|
|
4007
4208
|
xhr: xhrAdapter,
|
|
4008
|
-
fetch:
|
|
4209
|
+
fetch: {
|
|
4210
|
+
get: getFetch,
|
|
4211
|
+
}
|
|
4009
4212
|
};
|
|
4010
4213
|
|
|
4011
4214
|
utils$1.forEach(knownAdapters, (fn, value) => {
|
|
@@ -4024,7 +4227,7 @@ const renderReason = (reason) => `- ${reason}`;
|
|
|
4024
4227
|
const isResolvedHandle = (adapter) => utils$1.isFunction(adapter) || adapter === null || adapter === false;
|
|
4025
4228
|
|
|
4026
4229
|
const adapters = {
|
|
4027
|
-
getAdapter: (adapters) => {
|
|
4230
|
+
getAdapter: (adapters, config) => {
|
|
4028
4231
|
adapters = utils$1.isArray(adapters) ? adapters : [adapters];
|
|
4029
4232
|
|
|
4030
4233
|
const {length} = adapters;
|
|
@@ -4047,7 +4250,7 @@ const adapters = {
|
|
|
4047
4250
|
}
|
|
4048
4251
|
}
|
|
4049
4252
|
|
|
4050
|
-
if (adapter) {
|
|
4253
|
+
if (adapter && (utils$1.isFunction(adapter) || (adapter = adapter.get(config)))) {
|
|
4051
4254
|
break;
|
|
4052
4255
|
}
|
|
4053
4256
|
|
|
@@ -4115,7 +4318,7 @@ function dispatchRequest(config) {
|
|
|
4115
4318
|
config.headers.setContentType('application/x-www-form-urlencoded', false);
|
|
4116
4319
|
}
|
|
4117
4320
|
|
|
4118
|
-
const adapter = adapters.getAdapter(config.adapter || defaults$1.adapter);
|
|
4321
|
+
const adapter = adapters.getAdapter(config.adapter || defaults$1.adapter, config);
|
|
4119
4322
|
|
|
4120
4323
|
return adapter(config).then(function onAdapterResolution(response) {
|
|
4121
4324
|
throwIfCancellationRequested(config);
|
|
@@ -4386,8 +4589,8 @@ class Axios {
|
|
|
4386
4589
|
|
|
4387
4590
|
if (!synchronousRequestInterceptors) {
|
|
4388
4591
|
const chain = [dispatchRequest.bind(this), undefined];
|
|
4389
|
-
chain.unshift
|
|
4390
|
-
chain.push
|
|
4592
|
+
chain.unshift(...requestInterceptorChain);
|
|
4593
|
+
chain.push(...responseInterceptorChain);
|
|
4391
4594
|
len = chain.length;
|
|
4392
4595
|
|
|
4393
4596
|
promise = Promise.resolve(config);
|