axios 1.16.1 → 1.18.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 +94 -1
- package/README.md +267 -239
- package/dist/axios.js +454 -146
- package/dist/axios.min.js +3 -3
- package/dist/axios.min.js.map +1 -1
- package/dist/browser/axios.cjs +470 -99
- package/dist/esm/axios.js +470 -99
- package/dist/esm/axios.min.js +2 -2
- package/dist/esm/axios.min.js.map +1 -1
- package/dist/node/axios.cjs +638 -201
- package/index.d.cts +10 -3
- package/index.d.ts +6 -1
- package/lib/adapters/fetch.js +190 -35
- package/lib/adapters/http.js +192 -159
- package/lib/core/Axios.js +4 -2
- package/lib/core/AxiosHeaders.js +12 -9
- package/lib/core/buildFullPath.js +29 -1
- package/lib/core/mergeConfig.js +34 -0
- package/lib/defaults/transitional.js +2 -0
- package/lib/env/data.js +1 -1
- package/lib/helpers/Http2Sessions.js +119 -0
- package/lib/helpers/buildURL.js +6 -4
- package/lib/helpers/estimateDataURLDecodedBytes.js +16 -11
- package/lib/helpers/formDataToJSON.js +25 -3
- package/lib/helpers/formDataToStream.js +2 -2
- package/lib/helpers/resolveConfig.js +17 -9
- package/lib/helpers/shouldBypassProxy.js +33 -1
- package/lib/helpers/toFormData.js +41 -11
- package/lib/utils.js +97 -12
- package/package.json +29 -13
- package/dist/axios.js.map +0 -1
- package/dist/browser/axios.cjs.map +0 -1
- package/dist/esm/axios.js.map +0 -1
- package/dist/node/axios.cjs.map +0 -1
package/dist/esm/axios.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! Axios v1.
|
|
1
|
+
/*! Axios v1.18.0 Copyright (c) 2026 Matt Zabriskie and contributors */
|
|
2
2
|
/**
|
|
3
3
|
* Create a bound version of a function with a specified `this` context
|
|
4
4
|
*
|
|
@@ -18,6 +18,57 @@ const { toString } = Object.prototype;
|
|
|
18
18
|
const { getPrototypeOf } = Object;
|
|
19
19
|
const { iterator, toStringTag } = Symbol;
|
|
20
20
|
|
|
21
|
+
/* Creating a function that will check if an object has a property. */
|
|
22
|
+
const hasOwnProperty = (
|
|
23
|
+
({ hasOwnProperty }) =>
|
|
24
|
+
(obj, prop) =>
|
|
25
|
+
hasOwnProperty.call(obj, prop)
|
|
26
|
+
)(Object.prototype);
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Walk the prototype chain (excluding the shared Object.prototype) looking for
|
|
30
|
+
* an own `prop`. This distinguishes genuine own/inherited members — including
|
|
31
|
+
* class accessors and template prototypes — from members injected via
|
|
32
|
+
* Object.prototype pollution (e.g. `Object.prototype.username = '...'`), which
|
|
33
|
+
* live on Object.prototype itself and are therefore never matched.
|
|
34
|
+
*
|
|
35
|
+
* @param {*} thing The value whose chain to inspect
|
|
36
|
+
* @param {string|symbol} prop The property key to look for
|
|
37
|
+
*
|
|
38
|
+
* @returns {boolean} True when `prop` is owned below Object.prototype
|
|
39
|
+
*/
|
|
40
|
+
const hasOwnInPrototypeChain = (thing, prop) => {
|
|
41
|
+
let obj = thing;
|
|
42
|
+
const seen = [];
|
|
43
|
+
|
|
44
|
+
while (obj != null && obj !== Object.prototype) {
|
|
45
|
+
if (seen.indexOf(obj) !== -1) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
seen.push(obj);
|
|
49
|
+
|
|
50
|
+
if (hasOwnProperty(obj, prop)) {
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
obj = getPrototypeOf(obj);
|
|
54
|
+
}
|
|
55
|
+
return false;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Read `obj[prop]` only when it is safe from Object.prototype pollution. Own
|
|
60
|
+
* properties and members inherited from a non-Object.prototype source (a class
|
|
61
|
+
* instance or template object) are honored; a value reachable only through a
|
|
62
|
+
* polluted Object.prototype is ignored and `undefined` is returned.
|
|
63
|
+
*
|
|
64
|
+
* @param {*} obj The source object
|
|
65
|
+
* @param {string|symbol} prop The property key to read
|
|
66
|
+
*
|
|
67
|
+
* @returns {*} The resolved value, or undefined when unsafe/absent
|
|
68
|
+
*/
|
|
69
|
+
const getSafeProp = (obj, prop) =>
|
|
70
|
+
obj != null && hasOwnInPrototypeChain(obj, prop) ? obj[prop] : undefined;
|
|
71
|
+
|
|
21
72
|
const kindOf = ((cache) => (thing) => {
|
|
22
73
|
const str = toString.call(thing);
|
|
23
74
|
return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
|
|
@@ -143,7 +194,7 @@ const isBoolean = (thing) => thing === true || thing === false;
|
|
|
143
194
|
* @returns {boolean} True if value is a plain Object, otherwise false
|
|
144
195
|
*/
|
|
145
196
|
const isPlainObject = (val) => {
|
|
146
|
-
if (
|
|
197
|
+
if (!isObject(val)) {
|
|
147
198
|
return false;
|
|
148
199
|
}
|
|
149
200
|
|
|
@@ -151,9 +202,12 @@ const isPlainObject = (val) => {
|
|
|
151
202
|
return (
|
|
152
203
|
(prototype === null ||
|
|
153
204
|
prototype === Object.prototype ||
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
205
|
+
getPrototypeOf(prototype) === null) &&
|
|
206
|
+
// Treat any genuine (non-Object.prototype-polluted) Symbol.toStringTag or
|
|
207
|
+
// Symbol.iterator as evidence the value is a tagged/iterable type rather
|
|
208
|
+
// than a plain object, while ignoring keys injected onto Object.prototype.
|
|
209
|
+
!hasOwnInPrototypeChain(val, toStringTag) &&
|
|
210
|
+
!hasOwnInPrototypeChain(val, iterator)
|
|
157
211
|
);
|
|
158
212
|
};
|
|
159
213
|
|
|
@@ -422,7 +476,9 @@ function merge(...objs) {
|
|
|
422
476
|
return;
|
|
423
477
|
}
|
|
424
478
|
|
|
425
|
-
|
|
479
|
+
// findKey lowercases the key, so caseless lookup only applies to strings —
|
|
480
|
+
// symbol keys are identity-matched.
|
|
481
|
+
const targetKey = (caseless && typeof key === 'string' && findKey(result, key)) || key;
|
|
426
482
|
// Read via own-prop only — a bare `result[targetKey]` walks the prototype
|
|
427
483
|
// chain, so a polluted Object.prototype value could surface here and get
|
|
428
484
|
// copied into the merged result.
|
|
@@ -439,7 +495,24 @@ function merge(...objs) {
|
|
|
439
495
|
};
|
|
440
496
|
|
|
441
497
|
for (let i = 0, l = objs.length; i < l; i++) {
|
|
442
|
-
|
|
498
|
+
const source = objs[i];
|
|
499
|
+
if (!source || isBuffer(source)) {
|
|
500
|
+
continue;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
forEach(source, assignValue);
|
|
504
|
+
|
|
505
|
+
if (typeof source !== 'object' || isArray(source)) {
|
|
506
|
+
continue;
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
const symbols = Object.getOwnPropertySymbols(source);
|
|
510
|
+
for (let j = 0; j < symbols.length; j++) {
|
|
511
|
+
const symbol = symbols[j];
|
|
512
|
+
if (propertyIsEnumerable.call(source, symbol)) {
|
|
513
|
+
assignValue(source[symbol], symbol);
|
|
514
|
+
}
|
|
515
|
+
}
|
|
443
516
|
}
|
|
444
517
|
return result;
|
|
445
518
|
}
|
|
@@ -661,12 +734,7 @@ const toCamelCase = (str) => {
|
|
|
661
734
|
});
|
|
662
735
|
};
|
|
663
736
|
|
|
664
|
-
|
|
665
|
-
const hasOwnProperty = (
|
|
666
|
-
({ hasOwnProperty }) =>
|
|
667
|
-
(obj, prop) =>
|
|
668
|
-
hasOwnProperty.call(obj, prop)
|
|
669
|
-
)(Object.prototype);
|
|
737
|
+
const { propertyIsEnumerable } = Object.prototype;
|
|
670
738
|
|
|
671
739
|
/**
|
|
672
740
|
* Determine if a value is a RegExp object
|
|
@@ -879,6 +947,20 @@ const asap =
|
|
|
879
947
|
|
|
880
948
|
const isIterable = (thing) => thing != null && isFunction$1(thing[iterator]);
|
|
881
949
|
|
|
950
|
+
/**
|
|
951
|
+
* Determine if a value is iterable via an iterator that is NOT sourced solely
|
|
952
|
+
* from a polluted Object.prototype. Use this instead of `isIterable` whenever
|
|
953
|
+
* the iterable comes from untrusted input (e.g. user-supplied header sources),
|
|
954
|
+
* so `Object.prototype[Symbol.iterator] = ...` cannot turn an ordinary object
|
|
955
|
+
* into an attacker-controlled entries iterator.
|
|
956
|
+
*
|
|
957
|
+
* @param {*} thing The value to test
|
|
958
|
+
*
|
|
959
|
+
* @returns {boolean} True if value has a non-polluted iterator
|
|
960
|
+
*/
|
|
961
|
+
const isSafeIterable = (thing) =>
|
|
962
|
+
thing != null && hasOwnInPrototypeChain(thing, iterator) && isIterable(thing);
|
|
963
|
+
|
|
882
964
|
var utils$1 = {
|
|
883
965
|
isArray,
|
|
884
966
|
isArrayBuffer,
|
|
@@ -923,6 +1005,8 @@ var utils$1 = {
|
|
|
923
1005
|
isHTMLForm,
|
|
924
1006
|
hasOwnProperty,
|
|
925
1007
|
hasOwnProp: hasOwnProperty, // an alias to avoid ESLint no-prototype-builtins detection
|
|
1008
|
+
hasOwnInPrototypeChain,
|
|
1009
|
+
getSafeProp,
|
|
926
1010
|
reduceDescriptors,
|
|
927
1011
|
freezeMethods,
|
|
928
1012
|
toObjectSet,
|
|
@@ -939,6 +1023,7 @@ var utils$1 = {
|
|
|
939
1023
|
setImmediate: _setImmediate,
|
|
940
1024
|
asap,
|
|
941
1025
|
isIterable,
|
|
1026
|
+
isSafeIterable,
|
|
942
1027
|
};
|
|
943
1028
|
|
|
944
1029
|
// RawAxiosHeaders whose duplicates are ignored by node
|
|
@@ -1149,7 +1234,7 @@ let AxiosHeaders$1 = class AxiosHeaders {
|
|
|
1149
1234
|
const lHeader = normalizeHeader(_header);
|
|
1150
1235
|
|
|
1151
1236
|
if (!lHeader) {
|
|
1152
|
-
|
|
1237
|
+
return;
|
|
1153
1238
|
}
|
|
1154
1239
|
|
|
1155
1240
|
const key = utils$1.findKey(self, lHeader);
|
|
@@ -1171,20 +1256,23 @@ let AxiosHeaders$1 = class AxiosHeaders {
|
|
|
1171
1256
|
setHeaders(header, valueOrRewrite);
|
|
1172
1257
|
} else if (utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
|
1173
1258
|
setHeaders(parseHeaders(header), valueOrRewrite);
|
|
1174
|
-
} else if (utils$1.isObject(header) && utils$1.
|
|
1175
|
-
let obj =
|
|
1259
|
+
} else if (utils$1.isObject(header) && utils$1.isSafeIterable(header)) {
|
|
1260
|
+
let obj = Object.create(null),
|
|
1176
1261
|
dest,
|
|
1177
1262
|
key;
|
|
1178
1263
|
for (const entry of header) {
|
|
1179
1264
|
if (!utils$1.isArray(entry)) {
|
|
1180
|
-
throw TypeError('Object iterator must return a key-value pair');
|
|
1265
|
+
throw new TypeError('Object iterator must return a key-value pair');
|
|
1181
1266
|
}
|
|
1182
1267
|
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
: entry[1];
|
|
1268
|
+
key = entry[0];
|
|
1269
|
+
|
|
1270
|
+
if (utils$1.hasOwnProp(obj, key)) {
|
|
1271
|
+
dest = obj[key];
|
|
1272
|
+
obj[key] = utils$1.isArray(dest) ? [...dest, entry[1]] : [dest, entry[1]];
|
|
1273
|
+
} else {
|
|
1274
|
+
obj[key] = entry[1];
|
|
1275
|
+
}
|
|
1188
1276
|
}
|
|
1189
1277
|
|
|
1190
1278
|
setHeaders(obj, valueOrRewrite);
|
|
@@ -1578,6 +1666,10 @@ AxiosError$1.ERR_FORM_DATA_DEPTH_EXCEEDED = 'ERR_FORM_DATA_DEPTH_EXCEEDED';
|
|
|
1578
1666
|
// eslint-disable-next-line strict
|
|
1579
1667
|
var httpAdapter = null;
|
|
1580
1668
|
|
|
1669
|
+
// Default nesting limit shared with the inverse transform (formDataToJSON) so
|
|
1670
|
+
// the FormData <-> JSON round-trip stays symmetric.
|
|
1671
|
+
const DEFAULT_FORM_DATA_MAX_DEPTH = 100;
|
|
1672
|
+
|
|
1581
1673
|
/**
|
|
1582
1674
|
* Determines if the given thing is a array or js object.
|
|
1583
1675
|
*
|
|
@@ -1688,8 +1780,9 @@ function toFormData$1(obj, formData, options) {
|
|
|
1688
1780
|
const dots = options.dots;
|
|
1689
1781
|
const indexes = options.indexes;
|
|
1690
1782
|
const _Blob = options.Blob || (typeof Blob !== 'undefined' && Blob);
|
|
1691
|
-
const maxDepth = options.maxDepth === undefined ?
|
|
1783
|
+
const maxDepth = options.maxDepth === undefined ? DEFAULT_FORM_DATA_MAX_DEPTH : options.maxDepth;
|
|
1692
1784
|
const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
|
|
1785
|
+
const stack = [];
|
|
1693
1786
|
|
|
1694
1787
|
if (!utils$1.isFunction(visitor)) {
|
|
1695
1788
|
throw new TypeError('visitor must be a function');
|
|
@@ -1717,6 +1810,38 @@ function toFormData$1(obj, formData, options) {
|
|
|
1717
1810
|
return value;
|
|
1718
1811
|
}
|
|
1719
1812
|
|
|
1813
|
+
function throwIfMaxDepthExceeded(depth) {
|
|
1814
|
+
if (depth > maxDepth) {
|
|
1815
|
+
throw new AxiosError$1(
|
|
1816
|
+
'Object is too deeply nested (' + depth + ' levels). Max depth: ' + maxDepth,
|
|
1817
|
+
AxiosError$1.ERR_FORM_DATA_DEPTH_EXCEEDED
|
|
1818
|
+
);
|
|
1819
|
+
}
|
|
1820
|
+
}
|
|
1821
|
+
|
|
1822
|
+
function stringifyWithDepthLimit(value, depth) {
|
|
1823
|
+
if (maxDepth === Infinity) {
|
|
1824
|
+
return JSON.stringify(value);
|
|
1825
|
+
}
|
|
1826
|
+
|
|
1827
|
+
const ancestors = [];
|
|
1828
|
+
|
|
1829
|
+
return JSON.stringify(value, function limitDepth(_key, currentValue) {
|
|
1830
|
+
if (!utils$1.isObject(currentValue)) {
|
|
1831
|
+
return currentValue;
|
|
1832
|
+
}
|
|
1833
|
+
|
|
1834
|
+
while (ancestors.length && ancestors[ancestors.length - 1] !== this) {
|
|
1835
|
+
ancestors.pop();
|
|
1836
|
+
}
|
|
1837
|
+
|
|
1838
|
+
ancestors.push(currentValue);
|
|
1839
|
+
throwIfMaxDepthExceeded(depth + ancestors.length - 1);
|
|
1840
|
+
|
|
1841
|
+
return currentValue;
|
|
1842
|
+
});
|
|
1843
|
+
}
|
|
1844
|
+
|
|
1720
1845
|
/**
|
|
1721
1846
|
* Default visitor.
|
|
1722
1847
|
*
|
|
@@ -1740,7 +1865,7 @@ function toFormData$1(obj, formData, options) {
|
|
|
1740
1865
|
// eslint-disable-next-line no-param-reassign
|
|
1741
1866
|
key = metaTokens ? key : key.slice(0, -2);
|
|
1742
1867
|
// eslint-disable-next-line no-param-reassign
|
|
1743
|
-
value =
|
|
1868
|
+
value = stringifyWithDepthLimit(value, 1);
|
|
1744
1869
|
} else if (
|
|
1745
1870
|
(utils$1.isArray(value) && isFlatArray(value)) ||
|
|
1746
1871
|
((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value)))
|
|
@@ -1773,8 +1898,6 @@ function toFormData$1(obj, formData, options) {
|
|
|
1773
1898
|
return false;
|
|
1774
1899
|
}
|
|
1775
1900
|
|
|
1776
|
-
const stack = [];
|
|
1777
|
-
|
|
1778
1901
|
const exposedHelpers = Object.assign(predicates, {
|
|
1779
1902
|
defaultVisitor,
|
|
1780
1903
|
convertValue,
|
|
@@ -1784,15 +1907,10 @@ function toFormData$1(obj, formData, options) {
|
|
|
1784
1907
|
function build(value, path, depth = 0) {
|
|
1785
1908
|
if (utils$1.isUndefined(value)) return;
|
|
1786
1909
|
|
|
1787
|
-
|
|
1788
|
-
throw new AxiosError$1(
|
|
1789
|
-
'Object is too deeply nested (' + depth + ' levels). Max depth: ' + maxDepth,
|
|
1790
|
-
AxiosError$1.ERR_FORM_DATA_DEPTH_EXCEEDED
|
|
1791
|
-
);
|
|
1792
|
-
}
|
|
1910
|
+
throwIfMaxDepthExceeded(depth);
|
|
1793
1911
|
|
|
1794
1912
|
if (stack.indexOf(value) !== -1) {
|
|
1795
|
-
throw Error('Circular reference detected in ' + path.join('.'));
|
|
1913
|
+
throw new Error('Circular reference detected in ' + path.join('.'));
|
|
1796
1914
|
}
|
|
1797
1915
|
|
|
1798
1916
|
stack.push(value);
|
|
@@ -1905,15 +2023,17 @@ function buildURL(url, params, options) {
|
|
|
1905
2023
|
return url;
|
|
1906
2024
|
}
|
|
1907
2025
|
|
|
1908
|
-
const _encode = (options && options.encode) || encode;
|
|
1909
|
-
|
|
1910
2026
|
const _options = utils$1.isFunction(options)
|
|
1911
2027
|
? {
|
|
1912
2028
|
serialize: options,
|
|
1913
2029
|
}
|
|
1914
2030
|
: options;
|
|
1915
2031
|
|
|
1916
|
-
|
|
2032
|
+
// Read serializer options pollution-safely: own properties and methods on a
|
|
2033
|
+
// class/template prototype are honored, but values injected onto a polluted
|
|
2034
|
+
// Object.prototype are ignored.
|
|
2035
|
+
const _encode = utils$1.getSafeProp(_options, 'encode') || encode;
|
|
2036
|
+
const serializeFn = utils$1.getSafeProp(_options, 'serialize');
|
|
1917
2037
|
|
|
1918
2038
|
let serializedParams;
|
|
1919
2039
|
|
|
@@ -2009,6 +2129,8 @@ var transitionalDefaults = {
|
|
|
2009
2129
|
forcedJSONParsing: true,
|
|
2010
2130
|
clarifyTimeoutError: false,
|
|
2011
2131
|
legacyInterceptorReqResOrdering: true,
|
|
2132
|
+
advertiseZstdAcceptEncoding: false,
|
|
2133
|
+
validateStatusUndefinedResolves: true,
|
|
2012
2134
|
};
|
|
2013
2135
|
|
|
2014
2136
|
var URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
|
|
@@ -2100,6 +2222,17 @@ function toURLEncodedForm(data, options) {
|
|
|
2100
2222
|
});
|
|
2101
2223
|
}
|
|
2102
2224
|
|
|
2225
|
+
const MAX_DEPTH = DEFAULT_FORM_DATA_MAX_DEPTH;
|
|
2226
|
+
|
|
2227
|
+
function throwIfDepthExceeded(index) {
|
|
2228
|
+
if (index > MAX_DEPTH) {
|
|
2229
|
+
throw new AxiosError$1(
|
|
2230
|
+
'FormData field is too deeply nested (' + index + ' levels). Max depth: ' + MAX_DEPTH,
|
|
2231
|
+
AxiosError$1.ERR_FORM_DATA_DEPTH_EXCEEDED
|
|
2232
|
+
);
|
|
2233
|
+
}
|
|
2234
|
+
}
|
|
2235
|
+
|
|
2103
2236
|
/**
|
|
2104
2237
|
* It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']
|
|
2105
2238
|
*
|
|
@@ -2112,9 +2245,16 @@ function parsePropPath(name) {
|
|
|
2112
2245
|
// foo.x.y.z
|
|
2113
2246
|
// foo-x-y-z
|
|
2114
2247
|
// foo x y z
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2248
|
+
const path = [];
|
|
2249
|
+
const pattern = /\w+|\[(\w*)]/g;
|
|
2250
|
+
let match;
|
|
2251
|
+
|
|
2252
|
+
while ((match = pattern.exec(name)) !== null) {
|
|
2253
|
+
throwIfDepthExceeded(path.length);
|
|
2254
|
+
path.push(match[0] === '[]' ? '' : match[1] || match[0]);
|
|
2255
|
+
}
|
|
2256
|
+
|
|
2257
|
+
return path;
|
|
2118
2258
|
}
|
|
2119
2259
|
|
|
2120
2260
|
/**
|
|
@@ -2146,6 +2286,8 @@ function arrayToObject(arr) {
|
|
|
2146
2286
|
*/
|
|
2147
2287
|
function formDataToJSON(formData) {
|
|
2148
2288
|
function buildPath(path, value, target, index) {
|
|
2289
|
+
throwIfDepthExceeded(index);
|
|
2290
|
+
|
|
2149
2291
|
let name = path[index++];
|
|
2150
2292
|
|
|
2151
2293
|
if (name === '__proto__') return true;
|
|
@@ -2682,6 +2824,31 @@ function combineURLs(baseURL, relativeURL) {
|
|
|
2682
2824
|
: baseURL;
|
|
2683
2825
|
}
|
|
2684
2826
|
|
|
2827
|
+
const malformedHttpProtocol = /^https?:(?!\/\/)/i;
|
|
2828
|
+
const httpProtocolControlCharacters = /[\t\n\r]/g;
|
|
2829
|
+
|
|
2830
|
+
function stripLeadingC0ControlOrSpace(url) {
|
|
2831
|
+
let i = 0;
|
|
2832
|
+
while (i < url.length && url.charCodeAt(i) <= 0x20) {
|
|
2833
|
+
i++;
|
|
2834
|
+
}
|
|
2835
|
+
return url.slice(i);
|
|
2836
|
+
}
|
|
2837
|
+
|
|
2838
|
+
function normalizeURLForProtocolCheck(url) {
|
|
2839
|
+
return stripLeadingC0ControlOrSpace(url).replace(httpProtocolControlCharacters, '');
|
|
2840
|
+
}
|
|
2841
|
+
|
|
2842
|
+
function assertValidHttpProtocolURL(url, config) {
|
|
2843
|
+
if (typeof url === 'string' && malformedHttpProtocol.test(normalizeURLForProtocolCheck(url))) {
|
|
2844
|
+
throw new AxiosError$1(
|
|
2845
|
+
'Invalid URL: missing "//" after protocol',
|
|
2846
|
+
AxiosError$1.ERR_INVALID_URL,
|
|
2847
|
+
config
|
|
2848
|
+
);
|
|
2849
|
+
}
|
|
2850
|
+
}
|
|
2851
|
+
|
|
2685
2852
|
/**
|
|
2686
2853
|
* Creates a new URL by combining the baseURL with the requestedURL,
|
|
2687
2854
|
* only when the requestedURL is not already an absolute URL.
|
|
@@ -2692,9 +2859,11 @@ function combineURLs(baseURL, relativeURL) {
|
|
|
2692
2859
|
*
|
|
2693
2860
|
* @returns {string} The combined full path
|
|
2694
2861
|
*/
|
|
2695
|
-
function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
|
|
2862
|
+
function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls, config) {
|
|
2863
|
+
assertValidHttpProtocolURL(requestedURL, config);
|
|
2696
2864
|
let isRelativeUrl = !isAbsoluteURL(requestedURL);
|
|
2697
2865
|
if (baseURL && (isRelativeUrl || allowAbsoluteUrls === false)) {
|
|
2866
|
+
assertValidHttpProtocolURL(baseURL, config);
|
|
2698
2867
|
return combineURLs(baseURL, requestedURL);
|
|
2699
2868
|
}
|
|
2700
2869
|
return requestedURL;
|
|
@@ -2765,6 +2934,28 @@ function mergeConfig$1(config1, config2) {
|
|
|
2765
2934
|
}
|
|
2766
2935
|
}
|
|
2767
2936
|
|
|
2937
|
+
function getMergedTransitionalOption(prop) {
|
|
2938
|
+
const transitional2 = utils$1.hasOwnProp(config2, 'transitional') ? config2.transitional : undefined;
|
|
2939
|
+
|
|
2940
|
+
if (!utils$1.isUndefined(transitional2)) {
|
|
2941
|
+
if (utils$1.isPlainObject(transitional2)) {
|
|
2942
|
+
if (utils$1.hasOwnProp(transitional2, prop)) {
|
|
2943
|
+
return transitional2[prop];
|
|
2944
|
+
}
|
|
2945
|
+
} else {
|
|
2946
|
+
return undefined;
|
|
2947
|
+
}
|
|
2948
|
+
}
|
|
2949
|
+
|
|
2950
|
+
const transitional1 = utils$1.hasOwnProp(config1, 'transitional') ? config1.transitional : undefined;
|
|
2951
|
+
|
|
2952
|
+
if (utils$1.isPlainObject(transitional1) && utils$1.hasOwnProp(transitional1, prop)) {
|
|
2953
|
+
return transitional1[prop];
|
|
2954
|
+
}
|
|
2955
|
+
|
|
2956
|
+
return undefined;
|
|
2957
|
+
}
|
|
2958
|
+
|
|
2768
2959
|
// eslint-disable-next-line consistent-return
|
|
2769
2960
|
function mergeDirectKeys(a, b, prop) {
|
|
2770
2961
|
if (utils$1.hasOwnProp(config2, prop)) {
|
|
@@ -2817,6 +3008,18 @@ function mergeConfig$1(config1, config2) {
|
|
|
2817
3008
|
(utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
|
|
2818
3009
|
});
|
|
2819
3010
|
|
|
3011
|
+
if (
|
|
3012
|
+
utils$1.hasOwnProp(config2, 'validateStatus') &&
|
|
3013
|
+
utils$1.isUndefined(config2.validateStatus) &&
|
|
3014
|
+
getMergedTransitionalOption('validateStatusUndefinedResolves') === false
|
|
3015
|
+
) {
|
|
3016
|
+
if (utils$1.hasOwnProp(config1, 'validateStatus')) {
|
|
3017
|
+
config.validateStatus = getMergedValue(undefined, config1.validateStatus);
|
|
3018
|
+
} else {
|
|
3019
|
+
delete config.validateStatus;
|
|
3020
|
+
}
|
|
3021
|
+
}
|
|
3022
|
+
|
|
2820
3023
|
return config;
|
|
2821
3024
|
}
|
|
2822
3025
|
|
|
@@ -2843,12 +3046,12 @@ function setFormDataHeaders(headers, formHeaders, policy) {
|
|
|
2843
3046
|
*
|
|
2844
3047
|
* @returns {string} UTF-8 bytes as a Latin-1 string
|
|
2845
3048
|
*/
|
|
2846
|
-
const encodeUTF8 = (str) =>
|
|
3049
|
+
const encodeUTF8$1 = (str) =>
|
|
2847
3050
|
encodeURIComponent(str).replace(/%([0-9A-F]{2})/gi, (_, hex) =>
|
|
2848
3051
|
String.fromCharCode(parseInt(hex, 16))
|
|
2849
3052
|
);
|
|
2850
3053
|
|
|
2851
|
-
|
|
3054
|
+
function resolveConfig(config) {
|
|
2852
3055
|
const newConfig = mergeConfig$1({}, config);
|
|
2853
3056
|
|
|
2854
3057
|
// Read only own properties to prevent prototype pollution gadgets
|
|
@@ -2868,23 +3071,29 @@ var resolveConfig = (config) => {
|
|
|
2868
3071
|
newConfig.headers = headers = AxiosHeaders$1.from(headers);
|
|
2869
3072
|
|
|
2870
3073
|
newConfig.url = buildURL(
|
|
2871
|
-
buildFullPath(baseURL, url, allowAbsoluteUrls),
|
|
2872
|
-
|
|
2873
|
-
|
|
3074
|
+
buildFullPath(baseURL, url, allowAbsoluteUrls, newConfig),
|
|
3075
|
+
own('params'),
|
|
3076
|
+
own('paramsSerializer')
|
|
2874
3077
|
);
|
|
2875
3078
|
|
|
2876
3079
|
// HTTP basic authentication
|
|
2877
3080
|
if (auth) {
|
|
3081
|
+
const username = utils$1.getSafeProp(auth, 'username') || '';
|
|
3082
|
+
const password = utils$1.getSafeProp(auth, 'password') || '';
|
|
3083
|
+
|
|
2878
3084
|
headers.set(
|
|
2879
3085
|
'Authorization',
|
|
2880
|
-
'Basic ' +
|
|
2881
|
-
btoa((auth.username || '') + ':' + (auth.password ? encodeUTF8(auth.password) : ''))
|
|
3086
|
+
'Basic ' + btoa(username + ':' + (password ? encodeUTF8$1(password) : ''))
|
|
2882
3087
|
);
|
|
2883
3088
|
}
|
|
2884
3089
|
|
|
2885
3090
|
if (utils$1.isFormData(data)) {
|
|
2886
|
-
if (
|
|
2887
|
-
|
|
3091
|
+
if (
|
|
3092
|
+
platform.hasStandardBrowserEnv ||
|
|
3093
|
+
platform.hasStandardBrowserWebWorkerEnv ||
|
|
3094
|
+
utils$1.isReactNative(data)
|
|
3095
|
+
) {
|
|
3096
|
+
headers.setContentType(undefined); // browser/web worker/RN handles it
|
|
2888
3097
|
} else if (utils$1.isFunction(data.getHeaders)) {
|
|
2889
3098
|
// Node.js FormData (like form-data package)
|
|
2890
3099
|
setFormDataHeaders(headers, data.getHeaders(), own('formDataHeaderPolicy'));
|
|
@@ -2916,7 +3125,7 @@ var resolveConfig = (config) => {
|
|
|
2916
3125
|
}
|
|
2917
3126
|
|
|
2918
3127
|
return newConfig;
|
|
2919
|
-
}
|
|
3128
|
+
}
|
|
2920
3129
|
|
|
2921
3130
|
const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
|
|
2922
3131
|
|
|
@@ -3280,11 +3489,19 @@ const trackStream = (stream, chunkSize, onProgress, onFinish) => {
|
|
|
3280
3489
|
* Estimate decoded byte length of a data:// URL *without* allocating large buffers.
|
|
3281
3490
|
* - For base64: compute exact decoded size using length and padding;
|
|
3282
3491
|
* handle %XX at the character-count level (no string allocation).
|
|
3283
|
-
* - For non-base64:
|
|
3492
|
+
* - For non-base64: compute the exact percent-decoded UTF-8 byte length.
|
|
3284
3493
|
*
|
|
3285
3494
|
* @param {string} url
|
|
3286
3495
|
* @returns {number}
|
|
3287
3496
|
*/
|
|
3497
|
+
const isHexDigit = (charCode) =>
|
|
3498
|
+
(charCode >= 48 && charCode <= 57) ||
|
|
3499
|
+
(charCode >= 65 && charCode <= 70) ||
|
|
3500
|
+
(charCode >= 97 && charCode <= 102);
|
|
3501
|
+
|
|
3502
|
+
const isPercentEncodedByte = (str, i, len) =>
|
|
3503
|
+
i + 2 < len && isHexDigit(str.charCodeAt(i + 1)) && isHexDigit(str.charCodeAt(i + 2));
|
|
3504
|
+
|
|
3288
3505
|
function estimateDataURLDecodedBytes(url) {
|
|
3289
3506
|
if (!url || typeof url !== 'string') return 0;
|
|
3290
3507
|
if (!url.startsWith('data:')) return 0;
|
|
@@ -3304,9 +3521,7 @@ function estimateDataURLDecodedBytes(url) {
|
|
|
3304
3521
|
if (body.charCodeAt(i) === 37 /* '%' */ && i + 2 < len) {
|
|
3305
3522
|
const a = body.charCodeAt(i + 1);
|
|
3306
3523
|
const b = body.charCodeAt(i + 2);
|
|
3307
|
-
const isHex =
|
|
3308
|
-
((a >= 48 && a <= 57) || (a >= 65 && a <= 70) || (a >= 97 && a <= 102)) &&
|
|
3309
|
-
((b >= 48 && b <= 57) || (b >= 65 && b <= 70) || (b >= 97 && b <= 102));
|
|
3524
|
+
const isHex = isHexDigit(a) && isHexDigit(b);
|
|
3310
3525
|
|
|
3311
3526
|
if (isHex) {
|
|
3312
3527
|
effectiveLen -= 2;
|
|
@@ -3347,18 +3562,17 @@ function estimateDataURLDecodedBytes(url) {
|
|
|
3347
3562
|
return bytes > 0 ? bytes : 0;
|
|
3348
3563
|
}
|
|
3349
3564
|
|
|
3350
|
-
if (typeof Buffer !== 'undefined' && typeof Buffer.byteLength === 'function') {
|
|
3351
|
-
return Buffer.byteLength(body, 'utf8');
|
|
3352
|
-
}
|
|
3353
|
-
|
|
3354
3565
|
// Compute UTF-8 byte length directly from UTF-16 code units without allocating
|
|
3355
3566
|
// a byte buffer (TextEncoder.encode would defeat the DoS guard on large bodies).
|
|
3356
|
-
//
|
|
3357
|
-
//
|
|
3567
|
+
// Valid %XX triplets count as one decoded byte; this matches the bytes that
|
|
3568
|
+
// decodeURIComponent(body) would produce before Buffer re-encodes the string.
|
|
3358
3569
|
let bytes = 0;
|
|
3359
3570
|
for (let i = 0, len = body.length; i < len; i++) {
|
|
3360
3571
|
const c = body.charCodeAt(i);
|
|
3361
|
-
if (c
|
|
3572
|
+
if (c === 37 /* '%' */ && isPercentEncodedByte(body, i, len)) {
|
|
3573
|
+
bytes += 1;
|
|
3574
|
+
i += 2;
|
|
3575
|
+
} else if (c < 0x80) {
|
|
3362
3576
|
bytes += 1;
|
|
3363
3577
|
} else if (c < 0x800) {
|
|
3364
3578
|
bytes += 2;
|
|
@@ -3377,12 +3591,41 @@ function estimateDataURLDecodedBytes(url) {
|
|
|
3377
3591
|
return bytes;
|
|
3378
3592
|
}
|
|
3379
3593
|
|
|
3380
|
-
const VERSION$1 = "1.
|
|
3594
|
+
const VERSION$1 = "1.18.0";
|
|
3381
3595
|
|
|
3382
3596
|
const DEFAULT_CHUNK_SIZE = 64 * 1024;
|
|
3383
3597
|
|
|
3384
3598
|
const { isFunction } = utils$1;
|
|
3385
3599
|
|
|
3600
|
+
/**
|
|
3601
|
+
* Encode a UTF-8 string to a Latin-1 byte string for use with btoa().
|
|
3602
|
+
* This is a modern replacement for the deprecated unescape(encodeURIComponent(str)) pattern.
|
|
3603
|
+
*
|
|
3604
|
+
* @param {string} str The string to encode
|
|
3605
|
+
*
|
|
3606
|
+
* @returns {string} UTF-8 bytes as a Latin-1 string
|
|
3607
|
+
*/
|
|
3608
|
+
const encodeUTF8 = (str) =>
|
|
3609
|
+
encodeURIComponent(str).replace(/%([0-9A-F]{2})/gi, (_, hex) =>
|
|
3610
|
+
String.fromCharCode(parseInt(hex, 16))
|
|
3611
|
+
);
|
|
3612
|
+
|
|
3613
|
+
// Node's WHATWG URL parser returns `username` and `password` percent-encoded.
|
|
3614
|
+
// Decode before composing the `auth` option so credentials such as
|
|
3615
|
+
// `my%40email.com:pass` are sent as `my@email.com:pass`. Falls back to the
|
|
3616
|
+
// original value for malformed input so a bad encoding never throws.
|
|
3617
|
+
const decodeURIComponentSafe = (value) => {
|
|
3618
|
+
if (!utils$1.isString(value)) {
|
|
3619
|
+
return value;
|
|
3620
|
+
}
|
|
3621
|
+
|
|
3622
|
+
try {
|
|
3623
|
+
return decodeURIComponent(value);
|
|
3624
|
+
} catch (error) {
|
|
3625
|
+
return value;
|
|
3626
|
+
}
|
|
3627
|
+
};
|
|
3628
|
+
|
|
3386
3629
|
const test = (fn, ...args) => {
|
|
3387
3630
|
try {
|
|
3388
3631
|
return !!fn(...args);
|
|
@@ -3391,6 +3634,15 @@ const test = (fn, ...args) => {
|
|
|
3391
3634
|
}
|
|
3392
3635
|
};
|
|
3393
3636
|
|
|
3637
|
+
const maybeWithAuthCredentials = (url) => {
|
|
3638
|
+
const protocolIndex = url.indexOf('://');
|
|
3639
|
+
let urlToCheck = url;
|
|
3640
|
+
if (protocolIndex !== -1) {
|
|
3641
|
+
urlToCheck = urlToCheck.slice(protocolIndex + 3);
|
|
3642
|
+
}
|
|
3643
|
+
return urlToCheck.includes('@') || urlToCheck.includes(':');
|
|
3644
|
+
};
|
|
3645
|
+
|
|
3394
3646
|
const factory = (env) => {
|
|
3395
3647
|
const globalObject =
|
|
3396
3648
|
utils$1.global !== undefined && utils$1.global !== null
|
|
@@ -3538,6 +3790,7 @@ const factory = (env) => {
|
|
|
3538
3790
|
|
|
3539
3791
|
const hasMaxContentLength = utils$1.isNumber(maxContentLength) && maxContentLength > -1;
|
|
3540
3792
|
const hasMaxBodyLength = utils$1.isNumber(maxBodyLength) && maxBodyLength > -1;
|
|
3793
|
+
const own = (key) => (utils$1.hasOwnProp(config, key) ? config[key] : undefined);
|
|
3541
3794
|
|
|
3542
3795
|
let _fetch = envFetch || fetch;
|
|
3543
3796
|
|
|
@@ -3559,7 +3812,61 @@ const factory = (env) => {
|
|
|
3559
3812
|
|
|
3560
3813
|
let requestContentLength;
|
|
3561
3814
|
|
|
3815
|
+
// AxiosError we raise while the request body is being streamed. Captured
|
|
3816
|
+
// by identity so the catch block can surface it directly, regardless of
|
|
3817
|
+
// how the runtime wraps the resulting fetch rejection (undici exposes it
|
|
3818
|
+
// as `err.cause`; some browsers drop the original error entirely).
|
|
3819
|
+
let pendingBodyError = null;
|
|
3820
|
+
|
|
3821
|
+
const maxBodyLengthError = () =>
|
|
3822
|
+
new AxiosError$1(
|
|
3823
|
+
'Request body larger than maxBodyLength limit',
|
|
3824
|
+
AxiosError$1.ERR_BAD_REQUEST,
|
|
3825
|
+
config,
|
|
3826
|
+
request
|
|
3827
|
+
);
|
|
3828
|
+
|
|
3562
3829
|
try {
|
|
3830
|
+
// HTTP basic authentication
|
|
3831
|
+
let auth = undefined;
|
|
3832
|
+
const configAuth = own('auth');
|
|
3833
|
+
|
|
3834
|
+
if (configAuth) {
|
|
3835
|
+
const username = utils$1.getSafeProp(configAuth, 'username') || '';
|
|
3836
|
+
const password = utils$1.getSafeProp(configAuth, 'password') || '';
|
|
3837
|
+
auth = {
|
|
3838
|
+
username,
|
|
3839
|
+
password
|
|
3840
|
+
};
|
|
3841
|
+
}
|
|
3842
|
+
|
|
3843
|
+
if (maybeWithAuthCredentials(url)) {
|
|
3844
|
+
const parsedURL = new URL(url, platform.origin);
|
|
3845
|
+
|
|
3846
|
+
if (!auth && (parsedURL.username || parsedURL.password)) {
|
|
3847
|
+
const urlUsername = decodeURIComponentSafe(parsedURL.username);
|
|
3848
|
+
const urlPassword = decodeURIComponentSafe(parsedURL.password);
|
|
3849
|
+
auth = {
|
|
3850
|
+
username: urlUsername,
|
|
3851
|
+
password: urlPassword
|
|
3852
|
+
};
|
|
3853
|
+
}
|
|
3854
|
+
|
|
3855
|
+
if (parsedURL.username || parsedURL.password) {
|
|
3856
|
+
parsedURL.username = '';
|
|
3857
|
+
parsedURL.password = '';
|
|
3858
|
+
url = parsedURL.href;
|
|
3859
|
+
}
|
|
3860
|
+
}
|
|
3861
|
+
|
|
3862
|
+
if (auth) {
|
|
3863
|
+
headers.delete('authorization');
|
|
3864
|
+
headers.set(
|
|
3865
|
+
'Authorization',
|
|
3866
|
+
'Basic ' + btoa(encodeUTF8((auth.username || '') + ':' + (auth.password || '')))
|
|
3867
|
+
);
|
|
3868
|
+
}
|
|
3869
|
+
|
|
3563
3870
|
// Enforce maxContentLength for data: URLs up-front so we never materialize
|
|
3564
3871
|
// an oversized payload. The HTTP adapter applies the same check (see http.js
|
|
3565
3872
|
// "if (protocol === 'data:')" branch).
|
|
@@ -3575,53 +3882,96 @@ const factory = (env) => {
|
|
|
3575
3882
|
}
|
|
3576
3883
|
}
|
|
3577
3884
|
|
|
3578
|
-
// Enforce maxBodyLength against
|
|
3579
|
-
//
|
|
3580
|
-
//
|
|
3581
|
-
//
|
|
3885
|
+
// Enforce maxBodyLength against known-size bodies before dispatch using
|
|
3886
|
+
// the body's *actual* size — never a caller-declared Content-Length,
|
|
3887
|
+
// which could under-report to slip an oversized body past the check.
|
|
3888
|
+
// Unknown-size streams return undefined here and are counted per-chunk
|
|
3889
|
+
// below as fetch consumes them.
|
|
3582
3890
|
if (hasMaxBodyLength && method !== 'get' && method !== 'head') {
|
|
3583
|
-
const outboundLength = await
|
|
3584
|
-
if (
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
throw new AxiosError$1(
|
|
3590
|
-
'Request body larger than maxBodyLength limit',
|
|
3591
|
-
AxiosError$1.ERR_BAD_REQUEST,
|
|
3592
|
-
config,
|
|
3593
|
-
request
|
|
3594
|
-
);
|
|
3891
|
+
const outboundLength = await getBodyLength(data);
|
|
3892
|
+
if (typeof outboundLength === 'number' && isFinite(outboundLength)) {
|
|
3893
|
+
requestContentLength = outboundLength;
|
|
3894
|
+
if (outboundLength > maxBodyLength) {
|
|
3895
|
+
throw maxBodyLengthError();
|
|
3896
|
+
}
|
|
3595
3897
|
}
|
|
3596
3898
|
}
|
|
3597
3899
|
|
|
3900
|
+
// A streamed body under maxBodyLength must be counted as fetch consumes
|
|
3901
|
+
// it; its size is never trusted from a caller-declared Content-Length.
|
|
3902
|
+
const mustEnforceStreamBody =
|
|
3903
|
+
hasMaxBodyLength && (utils$1.isReadableStream(data) || utils$1.isStream(data));
|
|
3904
|
+
|
|
3905
|
+
const trackRequestStream = (stream, onProgress, flush) =>
|
|
3906
|
+
trackStream(
|
|
3907
|
+
stream,
|
|
3908
|
+
DEFAULT_CHUNK_SIZE,
|
|
3909
|
+
(loadedBytes) => {
|
|
3910
|
+
if (hasMaxBodyLength && loadedBytes > maxBodyLength) {
|
|
3911
|
+
throw (pendingBodyError = maxBodyLengthError());
|
|
3912
|
+
}
|
|
3913
|
+
onProgress && onProgress(loadedBytes);
|
|
3914
|
+
},
|
|
3915
|
+
flush
|
|
3916
|
+
);
|
|
3917
|
+
|
|
3598
3918
|
if (
|
|
3599
|
-
onUploadProgress &&
|
|
3600
3919
|
supportsRequestStream &&
|
|
3601
3920
|
method !== 'get' &&
|
|
3602
3921
|
method !== 'head' &&
|
|
3603
|
-
(
|
|
3922
|
+
(onUploadProgress || mustEnforceStreamBody)
|
|
3604
3923
|
) {
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3924
|
+
requestContentLength =
|
|
3925
|
+
requestContentLength == null ? await resolveBodyLength(headers, data) : requestContentLength;
|
|
3926
|
+
|
|
3927
|
+
// A declared length of 0 is only trusted to skip the wrap when we are
|
|
3928
|
+
// not enforcing a stream limit (which must not rely on that header).
|
|
3929
|
+
if (requestContentLength !== 0 || mustEnforceStreamBody) {
|
|
3930
|
+
let _request = new Request(url, {
|
|
3931
|
+
method: 'POST',
|
|
3932
|
+
body: data,
|
|
3933
|
+
duplex: 'half',
|
|
3934
|
+
});
|
|
3610
3935
|
|
|
3611
|
-
|
|
3936
|
+
let contentTypeHeader;
|
|
3612
3937
|
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3938
|
+
if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
|
|
3939
|
+
headers.setContentType(contentTypeHeader);
|
|
3940
|
+
}
|
|
3616
3941
|
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3942
|
+
if (_request.body) {
|
|
3943
|
+
const [onProgress, flush] =
|
|
3944
|
+
(onUploadProgress &&
|
|
3945
|
+
progressEventDecorator(
|
|
3946
|
+
requestContentLength,
|
|
3947
|
+
progressEventReducer(asyncDecorator(onUploadProgress))
|
|
3948
|
+
)) ||
|
|
3949
|
+
[];
|
|
3622
3950
|
|
|
3623
|
-
|
|
3951
|
+
data = trackRequestStream(_request.body, onProgress, flush);
|
|
3952
|
+
}
|
|
3624
3953
|
}
|
|
3954
|
+
} else if (
|
|
3955
|
+
mustEnforceStreamBody &&
|
|
3956
|
+
!isRequestSupported &&
|
|
3957
|
+
isReadableStreamSupported &&
|
|
3958
|
+
method !== 'get' &&
|
|
3959
|
+
method !== 'head'
|
|
3960
|
+
) {
|
|
3961
|
+
data = trackRequestStream(data);
|
|
3962
|
+
} else if (
|
|
3963
|
+
mustEnforceStreamBody &&
|
|
3964
|
+
isRequestSupported &&
|
|
3965
|
+
!supportsRequestStream &&
|
|
3966
|
+
method !== 'get' &&
|
|
3967
|
+
method !== 'head'
|
|
3968
|
+
) {
|
|
3969
|
+
throw new AxiosError$1(
|
|
3970
|
+
'Stream request bodies are not supported by the current fetch implementation',
|
|
3971
|
+
AxiosError$1.ERR_NOT_SUPPORT,
|
|
3972
|
+
config,
|
|
3973
|
+
request
|
|
3974
|
+
);
|
|
3625
3975
|
}
|
|
3626
3976
|
|
|
3627
3977
|
if (!utils$1.isString(withCredentials)) {
|
|
@@ -3664,10 +4014,12 @@ const factory = (env) => {
|
|
|
3664
4014
|
? _fetch(request, fetchOptions)
|
|
3665
4015
|
: _fetch(url, resolvedOptions));
|
|
3666
4016
|
|
|
4017
|
+
const responseHeaders = AxiosHeaders$1.from(response.headers);
|
|
4018
|
+
|
|
3667
4019
|
// Cheap pre-check: if the server honestly declares a content-length that
|
|
3668
4020
|
// already exceeds the cap, reject before we start streaming.
|
|
3669
4021
|
if (hasMaxContentLength) {
|
|
3670
|
-
const declaredLength = utils$1.toFiniteNumber(
|
|
4022
|
+
const declaredLength = utils$1.toFiniteNumber(responseHeaders.getContentLength());
|
|
3671
4023
|
if (declaredLength != null && declaredLength > maxContentLength) {
|
|
3672
4024
|
throw new AxiosError$1(
|
|
3673
4025
|
'maxContentLength size of ' + maxContentLength + ' exceeded',
|
|
@@ -3692,7 +4044,7 @@ const factory = (env) => {
|
|
|
3692
4044
|
options[prop] = response[prop];
|
|
3693
4045
|
});
|
|
3694
4046
|
|
|
3695
|
-
const responseContentLength = utils$1.toFiniteNumber(
|
|
4047
|
+
const responseContentLength = utils$1.toFiniteNumber(responseHeaders.getContentLength());
|
|
3696
4048
|
|
|
3697
4049
|
const [onProgress, flush] =
|
|
3698
4050
|
(onDownloadProgress &&
|
|
@@ -3787,6 +4139,23 @@ const factory = (env) => {
|
|
|
3787
4139
|
throw canceledError;
|
|
3788
4140
|
}
|
|
3789
4141
|
|
|
4142
|
+
// Surface a maxBodyLength violation we raised while the request body was
|
|
4143
|
+
// being streamed. Matching by identity (rather than reading
|
|
4144
|
+
// `err.cause.isAxiosError`) keeps the error deterministic across runtimes
|
|
4145
|
+
// and avoids both prototype-pollution reads and mis-attributing a foreign
|
|
4146
|
+
// AxiosError that merely happened to land in `err.cause`.
|
|
4147
|
+
if (pendingBodyError) {
|
|
4148
|
+
request && !pendingBodyError.request && (pendingBodyError.request = request);
|
|
4149
|
+
throw pendingBodyError;
|
|
4150
|
+
}
|
|
4151
|
+
|
|
4152
|
+
// Re-throw AxiosErrors we raised synchronously (data: URL / content-length
|
|
4153
|
+
// pre-checks, response size enforcement) without re-wrapping them.
|
|
4154
|
+
if (err instanceof AxiosError$1) {
|
|
4155
|
+
request && !err.request && (err.request = request);
|
|
4156
|
+
throw err;
|
|
4157
|
+
}
|
|
4158
|
+
|
|
3790
4159
|
if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
|
|
3791
4160
|
throw Object.assign(
|
|
3792
4161
|
new AxiosError$1(
|
|
@@ -4241,6 +4610,8 @@ let Axios$1 = class Axios {
|
|
|
4241
4610
|
forcedJSONParsing: validators.transitional(validators.boolean),
|
|
4242
4611
|
clarifyTimeoutError: validators.transitional(validators.boolean),
|
|
4243
4612
|
legacyInterceptorReqResOrdering: validators.transitional(validators.boolean),
|
|
4613
|
+
advertiseZstdAcceptEncoding: validators.transitional(validators.boolean),
|
|
4614
|
+
validateStatusUndefinedResolves: validators.transitional(validators.boolean),
|
|
4244
4615
|
},
|
|
4245
4616
|
false
|
|
4246
4617
|
);
|
|
@@ -4370,7 +4741,7 @@ let Axios$1 = class Axios {
|
|
|
4370
4741
|
|
|
4371
4742
|
getUri(config) {
|
|
4372
4743
|
config = mergeConfig$1(this.defaults, config);
|
|
4373
|
-
const fullPath = buildFullPath(config.baseURL, config.url, config.allowAbsoluteUrls);
|
|
4744
|
+
const fullPath = buildFullPath(config.baseURL, config.url, config.allowAbsoluteUrls, config);
|
|
4374
4745
|
return buildURL(fullPath, config.params, config.paramsSerializer);
|
|
4375
4746
|
}
|
|
4376
4747
|
};
|
|
@@ -4383,7 +4754,7 @@ utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoDa
|
|
|
4383
4754
|
mergeConfig$1(config || {}, {
|
|
4384
4755
|
method,
|
|
4385
4756
|
url,
|
|
4386
|
-
data: (config
|
|
4757
|
+
data: config && utils$1.hasOwnProp(config, 'data') ? config.data : undefined,
|
|
4387
4758
|
})
|
|
4388
4759
|
);
|
|
4389
4760
|
};
|