axios 0.31.1 → 0.32.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/AGENTS.md +38 -0
- package/CHANGELOG.md +10 -0
- package/CLAUDE.md +1 -0
- package/README.md +24 -4
- package/dist/axios.js +276 -77
- 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 +276 -77
- 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 +3 -0
- package/lib/adapters/http.js +291 -82
- package/lib/adapters/xhr.js +103 -33
- package/lib/core/AxiosError.js +79 -4
- package/lib/core/dispatchRequest.js +10 -5
- package/lib/core/mergeConfig.js +1 -0
- package/lib/defaults/index.js +3 -0
- package/lib/env/data.js +1 -1
- package/lib/helpers/AxiosURLSearchParams.js +18 -11
- package/lib/helpers/cookies.js +15 -2
- package/lib/helpers/defaultRedactKeys.js +3 -0
- package/lib/helpers/shouldBypassProxy.js +55 -1
- package/lib/utils.js +46 -21
- package/package.json +1 -1
package/dist/esm/axios.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// axios v0.
|
|
1
|
+
// axios v0.32.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);
|
|
@@ -52,8 +52,14 @@ function isUndefined(val) {
|
|
|
52
52
|
* @returns {boolean} True if value is a Buffer, otherwise false
|
|
53
53
|
*/
|
|
54
54
|
function isBuffer(val) {
|
|
55
|
-
return
|
|
56
|
-
|
|
55
|
+
return (
|
|
56
|
+
val !== null &&
|
|
57
|
+
!isUndefined(val) &&
|
|
58
|
+
val.constructor !== null &&
|
|
59
|
+
!isUndefined(val.constructor) &&
|
|
60
|
+
typeof val.constructor.isBuffer === 'function' &&
|
|
61
|
+
val.constructor.isBuffer(val)
|
|
62
|
+
);
|
|
57
63
|
}
|
|
58
64
|
|
|
59
65
|
/**
|
|
@@ -65,7 +71,6 @@ function isBuffer(val) {
|
|
|
65
71
|
*/
|
|
66
72
|
var isArrayBuffer = kindOfTest('ArrayBuffer');
|
|
67
73
|
|
|
68
|
-
|
|
69
74
|
/**
|
|
70
75
|
* Determine if a value is a view on an ArrayBuffer
|
|
71
76
|
*
|
|
@@ -74,10 +79,10 @@ var isArrayBuffer = kindOfTest('ArrayBuffer');
|
|
|
74
79
|
*/
|
|
75
80
|
function isArrayBufferView(val) {
|
|
76
81
|
var result;
|
|
77
|
-
if (
|
|
82
|
+
if (typeof ArrayBuffer !== 'undefined' && ArrayBuffer.isView) {
|
|
78
83
|
result = ArrayBuffer.isView(val);
|
|
79
84
|
} else {
|
|
80
|
-
result =
|
|
85
|
+
result = val && val.buffer && isArrayBuffer(val.buffer);
|
|
81
86
|
}
|
|
82
87
|
return result;
|
|
83
88
|
}
|
|
@@ -214,12 +219,14 @@ function isFormData(thing) {
|
|
|
214
219
|
// Reject non-objects (strings, numbers, booleans) up front — Object.getPrototypeOf
|
|
215
220
|
// throws a TypeError on primitives in ES5 environments.
|
|
216
221
|
if (!isObject(thing)) return false;
|
|
217
|
-
// Reject plain objects inheriting directly from Object.prototype so prototype-pollution gadgets can't spoof FormData
|
|
222
|
+
// Reject plain objects inheriting directly from Object.prototype so prototype-pollution gadgets can't spoof FormData.
|
|
218
223
|
var proto = Object.getPrototypeOf(thing);
|
|
219
224
|
if (!proto || proto === Object.prototype) return false;
|
|
220
225
|
if (!isFunction(thing.append)) return false;
|
|
221
|
-
return
|
|
222
|
-
|
|
226
|
+
return (
|
|
227
|
+
toString.call(thing) === pattern ||
|
|
228
|
+
(isFunction(thing.toString) && thing.toString() === pattern)
|
|
229
|
+
);
|
|
223
230
|
}
|
|
224
231
|
|
|
225
232
|
/**
|
|
@@ -237,7 +244,9 @@ var isURLSearchParams = kindOfTest('URLSearchParams');
|
|
|
237
244
|
* @returns {String} The String freed of excess whitespace
|
|
238
245
|
*/
|
|
239
246
|
function trim(str) {
|
|
240
|
-
return str.trim
|
|
247
|
+
return str.trim
|
|
248
|
+
? str.trim()
|
|
249
|
+
: str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
|
|
241
250
|
}
|
|
242
251
|
|
|
243
252
|
/**
|
|
@@ -257,10 +266,11 @@ function trim(str) {
|
|
|
257
266
|
*/
|
|
258
267
|
function isStandardBrowserEnv() {
|
|
259
268
|
var product;
|
|
260
|
-
if (
|
|
261
|
-
|
|
262
|
-
product === '
|
|
263
|
-
|
|
269
|
+
if (
|
|
270
|
+
typeof navigator !== 'undefined' &&
|
|
271
|
+
((product = navigator.product) === 'ReactNative' ||
|
|
272
|
+
product === 'NativeScript' ||
|
|
273
|
+
product === 'NS')
|
|
264
274
|
) {
|
|
265
275
|
return false;
|
|
266
276
|
}
|
|
@@ -325,14 +335,20 @@ function forEach(obj, fn) {
|
|
|
325
335
|
* @returns {Object} Result of all merge properties
|
|
326
336
|
*/
|
|
327
337
|
function merge(/* obj1, obj2, obj3, ... */) {
|
|
328
|
-
var result =
|
|
338
|
+
var result = Object.create(null);
|
|
329
339
|
function assignValue(val, key) {
|
|
340
|
+
var target;
|
|
341
|
+
|
|
330
342
|
if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
|
|
331
343
|
return;
|
|
332
344
|
}
|
|
333
345
|
|
|
334
|
-
|
|
335
|
-
|
|
346
|
+
target = Object.prototype.hasOwnProperty.call(result, key)
|
|
347
|
+
? result[key]
|
|
348
|
+
: undefined;
|
|
349
|
+
|
|
350
|
+
if (isPlainObject(target) && isPlainObject(val)) {
|
|
351
|
+
result[key] = merge(target, val);
|
|
336
352
|
} else if (isPlainObject(val)) {
|
|
337
353
|
result[key] = merge({}, val);
|
|
338
354
|
} else if (isArray(val)) {
|
|
@@ -374,7 +390,7 @@ function extend(a, b, thisArg) {
|
|
|
374
390
|
* @return {string} content value without BOM
|
|
375
391
|
*/
|
|
376
392
|
function stripBOM(content) {
|
|
377
|
-
if (content.charCodeAt(0) ===
|
|
393
|
+
if (content.charCodeAt(0) === 0xfeff) {
|
|
378
394
|
content = content.slice(1);
|
|
379
395
|
}
|
|
380
396
|
return content;
|
|
@@ -389,7 +405,10 @@ function stripBOM(content) {
|
|
|
389
405
|
*/
|
|
390
406
|
|
|
391
407
|
function inherits(constructor, superConstructor, props, descriptors) {
|
|
392
|
-
constructor.prototype = Object.create(
|
|
408
|
+
constructor.prototype = Object.create(
|
|
409
|
+
superConstructor.prototype,
|
|
410
|
+
descriptors
|
|
411
|
+
);
|
|
393
412
|
constructor.prototype.constructor = constructor;
|
|
394
413
|
props && Object.assign(constructor.prototype, props);
|
|
395
414
|
}
|
|
@@ -418,13 +437,20 @@ function toFlatObject(sourceObj, destObj, filter, propFilter) {
|
|
|
418
437
|
i = props.length;
|
|
419
438
|
while (i-- > 0) {
|
|
420
439
|
prop = props[i];
|
|
421
|
-
if (
|
|
440
|
+
if (
|
|
441
|
+
(!propFilter || propFilter(prop, sourceObj, destObj)) &&
|
|
442
|
+
!merged[prop]
|
|
443
|
+
) {
|
|
422
444
|
destObj[prop] = sourceObj[prop];
|
|
423
445
|
merged[prop] = true;
|
|
424
446
|
}
|
|
425
447
|
}
|
|
426
448
|
sourceObj = filter !== false && Object.getPrototypeOf(sourceObj);
|
|
427
|
-
} while (
|
|
449
|
+
} while (
|
|
450
|
+
sourceObj &&
|
|
451
|
+
(!filter || filter(sourceObj, destObj)) &&
|
|
452
|
+
sourceObj !== Object.prototype
|
|
453
|
+
);
|
|
428
454
|
|
|
429
455
|
return destObj;
|
|
430
456
|
}
|
|
@@ -446,7 +472,6 @@ function endsWith(str, searchString, position) {
|
|
|
446
472
|
return lastIndex !== -1 && lastIndex === position;
|
|
447
473
|
}
|
|
448
474
|
|
|
449
|
-
|
|
450
475
|
/**
|
|
451
476
|
* Returns new array from array like object or null if failed
|
|
452
477
|
* @param {*} [thing]
|
|
@@ -542,6 +567,82 @@ var utils = {
|
|
|
542
567
|
hasOwnProperty: hasOwnProperty
|
|
543
568
|
};
|
|
544
569
|
|
|
570
|
+
var defaultRedactKeys = ['authorization', 'proxy-authorization', 'cookie', 'set-cookie', 'x-api-key', 'password'];
|
|
571
|
+
|
|
572
|
+
var REDACTED_VALUE = '[REDACTED ****]';
|
|
573
|
+
|
|
574
|
+
function makeValueDescriptor(value) {
|
|
575
|
+
var descriptor = Object.create(null);
|
|
576
|
+
descriptor.value = value;
|
|
577
|
+
return descriptor;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
function getRedactKeys(config) {
|
|
581
|
+
// An empty array is treated as "no override" so an upstream `redact: []` cannot
|
|
582
|
+
// silently disable redaction. To opt out, pass non-string values or unset keys.
|
|
583
|
+
var override = config && utils.isArray(config.redact) && config.redact.length ? config.redact : null;
|
|
584
|
+
var redact = override || defaultRedactKeys;
|
|
585
|
+
var keys = {};
|
|
586
|
+
|
|
587
|
+
utils.forEach(redact, function eachRedactKey(key) {
|
|
588
|
+
if (typeof key === 'string') {
|
|
589
|
+
keys[key.toLowerCase()] = true;
|
|
590
|
+
}
|
|
591
|
+
});
|
|
592
|
+
|
|
593
|
+
return keys;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
function shouldRedact(key, keys) {
|
|
597
|
+
return typeof key === 'string' && keys[key.toLowerCase()];
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
var CIRCULAR_VALUE = '[Circular]';
|
|
601
|
+
|
|
602
|
+
function serializeConfigValue(value, keys, key, seen) {
|
|
603
|
+
var result;
|
|
604
|
+
|
|
605
|
+
if (shouldRedact(key, keys)) {
|
|
606
|
+
return REDACTED_VALUE;
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
if (utils.isArray(value)) {
|
|
610
|
+
if (seen.indexOf(value) !== -1) {
|
|
611
|
+
return CIRCULAR_VALUE;
|
|
612
|
+
}
|
|
613
|
+
seen.push(value);
|
|
614
|
+
result = [];
|
|
615
|
+
utils.forEach(value, function eachArrayValue(item, index) {
|
|
616
|
+
result[index] = serializeConfigValue(item, keys, index, seen);
|
|
617
|
+
});
|
|
618
|
+
seen.pop();
|
|
619
|
+
return result;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
if (utils.isPlainObject(value)) {
|
|
623
|
+
if (seen.indexOf(value) !== -1) {
|
|
624
|
+
return CIRCULAR_VALUE;
|
|
625
|
+
}
|
|
626
|
+
seen.push(value);
|
|
627
|
+
result = {};
|
|
628
|
+
utils.forEach(value, function eachObjectValue(item, itemKey) {
|
|
629
|
+
result[itemKey] = serializeConfigValue(item, keys, itemKey, seen);
|
|
630
|
+
});
|
|
631
|
+
seen.pop();
|
|
632
|
+
return result;
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
return value;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
function serializeConfig(config) {
|
|
639
|
+
if (!config) {
|
|
640
|
+
return config;
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
return serializeConfigValue(config, getRedactKeys(config), undefined, []);
|
|
644
|
+
}
|
|
645
|
+
|
|
545
646
|
/**
|
|
546
647
|
* Create an Error with the specified message, config, error code, request and response.
|
|
547
648
|
*
|
|
@@ -584,7 +685,7 @@ utils.inherits(AxiosError, Error, {
|
|
|
584
685
|
columnNumber: this.columnNumber,
|
|
585
686
|
stack: this.stack,
|
|
586
687
|
// Axios
|
|
587
|
-
config: this.config,
|
|
688
|
+
config: serializeConfig(this.config),
|
|
588
689
|
code: this.code,
|
|
589
690
|
status: this.response && this.response.status ? this.response.status : null
|
|
590
691
|
};
|
|
@@ -592,7 +693,7 @@ utils.inherits(AxiosError, Error, {
|
|
|
592
693
|
});
|
|
593
694
|
|
|
594
695
|
var prototype$1 = AxiosError.prototype;
|
|
595
|
-
var descriptors =
|
|
696
|
+
var descriptors = Object.create(null);
|
|
596
697
|
|
|
597
698
|
[
|
|
598
699
|
'ERR_BAD_OPTION_VALUE',
|
|
@@ -610,11 +711,11 @@ var descriptors = {};
|
|
|
610
711
|
'ERR_FORM_DATA_DEPTH_EXCEEDED'
|
|
611
712
|
// eslint-disable-next-line func-names
|
|
612
713
|
].forEach(function(code) {
|
|
613
|
-
descriptors[code] =
|
|
714
|
+
descriptors[code] = makeValueDescriptor(code);
|
|
614
715
|
});
|
|
615
716
|
|
|
616
717
|
Object.defineProperties(AxiosError, descriptors);
|
|
617
|
-
Object.defineProperty(prototype$1, 'isAxiosError',
|
|
718
|
+
Object.defineProperty(prototype$1, 'isAxiosError', makeValueDescriptor(true));
|
|
618
719
|
|
|
619
720
|
// eslint-disable-next-line func-names
|
|
620
721
|
AxiosError.from = function(error, code, config, request, response, customProps) {
|
|
@@ -829,7 +930,7 @@ function toFormData(obj, formData, options) {
|
|
|
829
930
|
var toFormData_1 = toFormData;
|
|
830
931
|
|
|
831
932
|
function encode$1(str) {
|
|
832
|
-
// Do not map `%00` back to a raw null byte
|
|
933
|
+
// Do not map `%00` back to a raw null byte: that reversed
|
|
833
934
|
// the safe percent-encoding from encodeURIComponent and enabled null byte injection.
|
|
834
935
|
var charMap = {
|
|
835
936
|
'!': '%21',
|
|
@@ -839,9 +940,12 @@ function encode$1(str) {
|
|
|
839
940
|
'~': '%7E',
|
|
840
941
|
'%20': '+'
|
|
841
942
|
};
|
|
842
|
-
return encodeURIComponent(str).replace(
|
|
843
|
-
|
|
844
|
-
|
|
943
|
+
return encodeURIComponent(str).replace(
|
|
944
|
+
/[!'\(\)~]|%20/g,
|
|
945
|
+
function replacer(match) {
|
|
946
|
+
return charMap[match];
|
|
947
|
+
}
|
|
948
|
+
);
|
|
845
949
|
}
|
|
846
950
|
|
|
847
951
|
function AxiosURLSearchParams(params, options) {
|
|
@@ -857,13 +961,17 @@ prototype.append = function append(name, value) {
|
|
|
857
961
|
};
|
|
858
962
|
|
|
859
963
|
prototype.toString = function toString(encoder) {
|
|
860
|
-
var _encode = encoder
|
|
861
|
-
|
|
862
|
-
|
|
964
|
+
var _encode = encoder
|
|
965
|
+
? function(value) {
|
|
966
|
+
return encoder.call(this, value, encode$1);
|
|
967
|
+
}
|
|
968
|
+
: encode$1;
|
|
863
969
|
|
|
864
|
-
return this._pairs
|
|
865
|
-
|
|
866
|
-
|
|
970
|
+
return this._pairs
|
|
971
|
+
.map(function each(pair) {
|
|
972
|
+
return _encode(pair[0]) + '=' + _encode(pair[1]);
|
|
973
|
+
}, '')
|
|
974
|
+
.join('&');
|
|
867
975
|
};
|
|
868
976
|
|
|
869
977
|
var AxiosURLSearchParams_1 = AxiosURLSearchParams;
|
|
@@ -1146,8 +1254,21 @@ var cookies = (
|
|
|
1146
1254
|
},
|
|
1147
1255
|
|
|
1148
1256
|
read: function read(name) {
|
|
1149
|
-
var
|
|
1150
|
-
|
|
1257
|
+
var nameEQ = name + '=';
|
|
1258
|
+
var cookies = document.cookie.split(';');
|
|
1259
|
+
var cookie;
|
|
1260
|
+
|
|
1261
|
+
for (var i = 0; i < cookies.length; i++) {
|
|
1262
|
+
cookie = cookies[i];
|
|
1263
|
+
while (cookie.charAt(0) === ' ') {
|
|
1264
|
+
cookie = cookie.substring(1);
|
|
1265
|
+
}
|
|
1266
|
+
if (cookie.indexOf(nameEQ) === 0) {
|
|
1267
|
+
return decodeURIComponent(cookie.substring(nameEQ.length));
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
return null;
|
|
1151
1272
|
},
|
|
1152
1273
|
|
|
1153
1274
|
remove: function remove(name) {
|
|
@@ -1356,8 +1477,10 @@ var xhr = function xhrAdapter(config) {
|
|
|
1356
1477
|
var requestData = config.data;
|
|
1357
1478
|
var requestHeaders = config.headers;
|
|
1358
1479
|
var responseType = config.responseType;
|
|
1359
|
-
// Guard against prototype pollution
|
|
1360
|
-
var withXSRFToken = utils.hasOwnProperty(config, 'withXSRFToken')
|
|
1480
|
+
// Guard against prototype pollution: only honor own properties.
|
|
1481
|
+
var withXSRFToken = utils.hasOwnProperty(config, 'withXSRFToken')
|
|
1482
|
+
? config.withXSRFToken
|
|
1483
|
+
: undefined;
|
|
1361
1484
|
var onCanceled;
|
|
1362
1485
|
function done() {
|
|
1363
1486
|
if (config.cancelToken) {
|
|
@@ -1378,13 +1501,23 @@ var xhr = function xhrAdapter(config) {
|
|
|
1378
1501
|
// HTTP basic authentication
|
|
1379
1502
|
if (config.auth) {
|
|
1380
1503
|
var username = config.auth.username || '';
|
|
1381
|
-
var password = config.auth.password
|
|
1504
|
+
var password = config.auth.password
|
|
1505
|
+
? unescape(encodeURIComponent(config.auth.password))
|
|
1506
|
+
: '';
|
|
1382
1507
|
requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
|
|
1383
1508
|
}
|
|
1384
1509
|
|
|
1385
|
-
var fullPath = buildFullPath(
|
|
1510
|
+
var fullPath = buildFullPath(
|
|
1511
|
+
config.baseURL,
|
|
1512
|
+
config.url,
|
|
1513
|
+
config.allowAbsoluteUrls
|
|
1514
|
+
);
|
|
1386
1515
|
|
|
1387
|
-
request.open(
|
|
1516
|
+
request.open(
|
|
1517
|
+
config.method.toUpperCase(),
|
|
1518
|
+
buildURL(fullPath, config.params, config.paramsSerializer),
|
|
1519
|
+
true
|
|
1520
|
+
);
|
|
1388
1521
|
|
|
1389
1522
|
// Set the request timeout in MS
|
|
1390
1523
|
request.timeout = config.timeout;
|
|
@@ -1394,9 +1527,14 @@ var xhr = function xhrAdapter(config) {
|
|
|
1394
1527
|
return;
|
|
1395
1528
|
}
|
|
1396
1529
|
// Prepare the response
|
|
1397
|
-
var responseHeaders =
|
|
1398
|
-
|
|
1399
|
-
|
|
1530
|
+
var responseHeaders =
|
|
1531
|
+
'getAllResponseHeaders' in request
|
|
1532
|
+
? parseHeaders(request.getAllResponseHeaders())
|
|
1533
|
+
: null;
|
|
1534
|
+
var responseData =
|
|
1535
|
+
!responseType || responseType === 'text' || responseType === 'json'
|
|
1536
|
+
? request.responseText
|
|
1537
|
+
: request.response;
|
|
1400
1538
|
var response = {
|
|
1401
1539
|
data: responseData,
|
|
1402
1540
|
status: request.status,
|
|
@@ -1406,13 +1544,17 @@ var xhr = function xhrAdapter(config) {
|
|
|
1406
1544
|
request: request
|
|
1407
1545
|
};
|
|
1408
1546
|
|
|
1409
|
-
settle(
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1547
|
+
settle(
|
|
1548
|
+
function _resolve(value) {
|
|
1549
|
+
resolve(value);
|
|
1550
|
+
done();
|
|
1551
|
+
},
|
|
1552
|
+
function _reject(err) {
|
|
1553
|
+
reject(err);
|
|
1554
|
+
done();
|
|
1555
|
+
},
|
|
1556
|
+
response
|
|
1557
|
+
);
|
|
1416
1558
|
|
|
1417
1559
|
// Clean up request
|
|
1418
1560
|
request = null;
|
|
@@ -1432,7 +1574,10 @@ var xhr = function xhrAdapter(config) {
|
|
|
1432
1574
|
// handled by onerror instead
|
|
1433
1575
|
// With one exception: request that using file: protocol, most browsers
|
|
1434
1576
|
// will return status as 0 even though it's a successful request
|
|
1435
|
-
if (
|
|
1577
|
+
if (
|
|
1578
|
+
request.status === 0 &&
|
|
1579
|
+
!(request.responseURL && request.responseURL.indexOf('file:') === 0)
|
|
1580
|
+
) {
|
|
1436
1581
|
return;
|
|
1437
1582
|
}
|
|
1438
1583
|
// readystate handler is calling before onerror or ontimeout handlers,
|
|
@@ -1447,7 +1592,14 @@ var xhr = function xhrAdapter(config) {
|
|
|
1447
1592
|
return;
|
|
1448
1593
|
}
|
|
1449
1594
|
|
|
1450
|
-
reject(
|
|
1595
|
+
reject(
|
|
1596
|
+
new AxiosError_1(
|
|
1597
|
+
'Request aborted',
|
|
1598
|
+
AxiosError_1.ECONNABORTED,
|
|
1599
|
+
config,
|
|
1600
|
+
request
|
|
1601
|
+
)
|
|
1602
|
+
);
|
|
1451
1603
|
|
|
1452
1604
|
// Clean up request
|
|
1453
1605
|
request = null;
|
|
@@ -1457,7 +1609,14 @@ var xhr = function xhrAdapter(config) {
|
|
|
1457
1609
|
request.onerror = function handleError() {
|
|
1458
1610
|
// Real errors are hidden from us by the browser
|
|
1459
1611
|
// onerror should only fire if it's a network error
|
|
1460
|
-
reject(
|
|
1612
|
+
reject(
|
|
1613
|
+
new AxiosError_1(
|
|
1614
|
+
'Network Error',
|
|
1615
|
+
AxiosError_1.ERR_NETWORK,
|
|
1616
|
+
config,
|
|
1617
|
+
request
|
|
1618
|
+
)
|
|
1619
|
+
);
|
|
1461
1620
|
|
|
1462
1621
|
// Clean up request
|
|
1463
1622
|
request = null;
|
|
@@ -1465,16 +1624,23 @@ var xhr = function xhrAdapter(config) {
|
|
|
1465
1624
|
|
|
1466
1625
|
// Handle timeout
|
|
1467
1626
|
request.ontimeout = function handleTimeout() {
|
|
1468
|
-
var timeoutErrorMessage = config.timeout
|
|
1627
|
+
var timeoutErrorMessage = config.timeout
|
|
1628
|
+
? 'timeout of ' + config.timeout + 'ms exceeded'
|
|
1629
|
+
: 'timeout exceeded';
|
|
1469
1630
|
var transitional$1 = config.transitional || transitional;
|
|
1470
1631
|
if (config.timeoutErrorMessage) {
|
|
1471
1632
|
timeoutErrorMessage = config.timeoutErrorMessage;
|
|
1472
1633
|
}
|
|
1473
|
-
reject(
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1634
|
+
reject(
|
|
1635
|
+
new AxiosError_1(
|
|
1636
|
+
timeoutErrorMessage,
|
|
1637
|
+
transitional$1.clarifyTimeoutError
|
|
1638
|
+
? AxiosError_1.ETIMEDOUT
|
|
1639
|
+
: AxiosError_1.ECONNABORTED,
|
|
1640
|
+
config,
|
|
1641
|
+
request
|
|
1642
|
+
)
|
|
1643
|
+
);
|
|
1478
1644
|
|
|
1479
1645
|
// Clean up request
|
|
1480
1646
|
request = null;
|
|
@@ -1488,10 +1654,16 @@ var xhr = function xhrAdapter(config) {
|
|
|
1488
1654
|
if (utils.isFunction(withXSRFToken)) {
|
|
1489
1655
|
withXSRFToken = withXSRFToken(config);
|
|
1490
1656
|
}
|
|
1491
|
-
// Strict boolean check
|
|
1492
|
-
if (
|
|
1657
|
+
// Strict boolean check: only `true` short-circuits the same-origin guard.
|
|
1658
|
+
if (
|
|
1659
|
+
withXSRFToken === true ||
|
|
1660
|
+
(withXSRFToken !== false && isURLSameOrigin(fullPath))
|
|
1661
|
+
) {
|
|
1493
1662
|
// Add xsrf header
|
|
1494
|
-
var xsrfValue =
|
|
1663
|
+
var xsrfValue =
|
|
1664
|
+
config.xsrfHeaderName &&
|
|
1665
|
+
config.xsrfCookieName &&
|
|
1666
|
+
cookies.read(config.xsrfCookieName);
|
|
1495
1667
|
if (xsrfValue) {
|
|
1496
1668
|
requestHeaders[config.xsrfHeaderName] = xsrfValue;
|
|
1497
1669
|
}
|
|
@@ -1501,7 +1673,10 @@ var xhr = function xhrAdapter(config) {
|
|
|
1501
1673
|
// Add headers to the request
|
|
1502
1674
|
if ('setRequestHeader' in request) {
|
|
1503
1675
|
utils.forEach(requestHeaders, function setRequestHeader(val, key) {
|
|
1504
|
-
if (
|
|
1676
|
+
if (
|
|
1677
|
+
typeof requestData === 'undefined' &&
|
|
1678
|
+
key.toLowerCase() === 'content-type'
|
|
1679
|
+
) {
|
|
1505
1680
|
// Remove Content-Type if data is undefined
|
|
1506
1681
|
delete requestHeaders[key];
|
|
1507
1682
|
} else {
|
|
@@ -1538,30 +1713,46 @@ var xhr = function xhrAdapter(config) {
|
|
|
1538
1713
|
if (!request) {
|
|
1539
1714
|
return;
|
|
1540
1715
|
}
|
|
1541
|
-
reject(
|
|
1716
|
+
reject(
|
|
1717
|
+
!cancel || cancel.type
|
|
1718
|
+
? new CanceledError_1(null, config, request)
|
|
1719
|
+
: cancel
|
|
1720
|
+
);
|
|
1542
1721
|
request.abort();
|
|
1543
1722
|
request = null;
|
|
1544
1723
|
};
|
|
1545
1724
|
|
|
1546
1725
|
config.cancelToken && config.cancelToken.subscribe(onCanceled);
|
|
1547
1726
|
if (config.signal) {
|
|
1548
|
-
config.signal.aborted
|
|
1727
|
+
config.signal.aborted
|
|
1728
|
+
? onCanceled()
|
|
1729
|
+
: config.signal.addEventListener('abort', onCanceled);
|
|
1549
1730
|
}
|
|
1550
1731
|
}
|
|
1551
1732
|
|
|
1552
1733
|
// false, 0 (zero number), and '' (empty string) are valid JSON values
|
|
1553
|
-
if (
|
|
1734
|
+
if (
|
|
1735
|
+
!requestData &&
|
|
1736
|
+
requestData !== false &&
|
|
1737
|
+
requestData !== 0 &&
|
|
1738
|
+
requestData !== ''
|
|
1739
|
+
) {
|
|
1554
1740
|
requestData = null;
|
|
1555
1741
|
}
|
|
1556
1742
|
|
|
1557
1743
|
var protocol = parseProtocol(fullPath);
|
|
1558
1744
|
|
|
1559
1745
|
if (protocol && platform.protocols.indexOf(protocol) === -1) {
|
|
1560
|
-
reject(
|
|
1746
|
+
reject(
|
|
1747
|
+
new AxiosError_1(
|
|
1748
|
+
'Unsupported protocol ' + protocol + ':',
|
|
1749
|
+
AxiosError_1.ERR_BAD_REQUEST,
|
|
1750
|
+
config
|
|
1751
|
+
)
|
|
1752
|
+
);
|
|
1561
1753
|
return;
|
|
1562
1754
|
}
|
|
1563
1755
|
|
|
1564
|
-
|
|
1565
1756
|
// Send the request
|
|
1566
1757
|
request.send(requestData);
|
|
1567
1758
|
});
|
|
@@ -1709,6 +1900,8 @@ var defaults = {
|
|
|
1709
1900
|
maxContentLength: -1,
|
|
1710
1901
|
maxBodyLength: -1,
|
|
1711
1902
|
|
|
1903
|
+
redact: defaultRedactKeys.slice(),
|
|
1904
|
+
|
|
1712
1905
|
env: {
|
|
1713
1906
|
FormData: platform.classes.FormData,
|
|
1714
1907
|
Blob: platform.classes.Blob
|
|
@@ -1815,11 +2008,16 @@ var dispatchRequest = function dispatchRequest(config) {
|
|
|
1815
2008
|
normalizeHeaderName(config.headers, 'Content-Type');
|
|
1816
2009
|
|
|
1817
2010
|
// Flatten headers
|
|
1818
|
-
config.headers
|
|
1819
|
-
config.headers.common
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
2011
|
+
var commonHeaders = utils.hasOwnProperty(config.headers, 'common') && config.headers.common
|
|
2012
|
+
? config.headers.common
|
|
2013
|
+
: {};
|
|
2014
|
+
var methodHeaders = config.method &&
|
|
2015
|
+
utils.hasOwnProperty(config.headers, config.method) &&
|
|
2016
|
+
config.headers[config.method]
|
|
2017
|
+
? config.headers[config.method]
|
|
2018
|
+
: {};
|
|
2019
|
+
|
|
2020
|
+
config.headers = utils.merge(commonHeaders, methodHeaders, config.headers);
|
|
1823
2021
|
|
|
1824
2022
|
utils.forEach(
|
|
1825
2023
|
['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
|
|
@@ -1964,6 +2162,7 @@ var mergeConfig = function mergeConfig(config1, config2) {
|
|
|
1964
2162
|
'httpsAgent': defaultToConfig2,
|
|
1965
2163
|
'cancelToken': defaultToConfig2,
|
|
1966
2164
|
'socketPath': defaultToConfig2,
|
|
2165
|
+
'allowedSocketPaths': defaultToConfig2,
|
|
1967
2166
|
'responseEncoding': defaultToConfig2,
|
|
1968
2167
|
'validateStatus': mergeDirectKeys
|
|
1969
2168
|
};
|
|
@@ -1981,7 +2180,7 @@ var mergeConfig = function mergeConfig(config1, config2) {
|
|
|
1981
2180
|
};
|
|
1982
2181
|
|
|
1983
2182
|
var data = {
|
|
1984
|
-
"version": "0.
|
|
2183
|
+
"version": "0.32.0"
|
|
1985
2184
|
};
|
|
1986
2185
|
|
|
1987
2186
|
var VERSION = data.version;
|