axios 1.1.3 → 1.3.4

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.

Potentially problematic release.


This version of axios might be problematic. Click here for more details.

Files changed (48) hide show
  1. package/CHANGELOG.md +312 -75
  2. package/{UPGRADE_GUIDE.md → MIGRATION_GUIDE.md} +1 -1
  3. package/README.md +64 -25
  4. package/dist/axios.js +888 -582
  5. package/dist/axios.js.map +1 -1
  6. package/dist/axios.min.js +1 -1
  7. package/dist/axios.min.js.map +1 -1
  8. package/dist/browser/axios.cjs +3191 -0
  9. package/dist/browser/axios.cjs.map +1 -0
  10. package/dist/esm/axios.js +889 -626
  11. package/dist/esm/axios.js.map +1 -1
  12. package/dist/esm/axios.min.js +1 -1
  13. package/dist/esm/axios.min.js.map +1 -1
  14. package/dist/node/axios.cjs +1001 -575
  15. package/dist/node/axios.cjs.map +1 -1
  16. package/index.d.cts +528 -0
  17. package/index.d.ts +116 -56
  18. package/index.js +12 -3
  19. package/lib/adapters/adapters.js +59 -0
  20. package/lib/adapters/http.js +118 -57
  21. package/lib/adapters/xhr.js +7 -4
  22. package/lib/axios.js +13 -3
  23. package/lib/core/Axios.js +10 -8
  24. package/lib/core/AxiosError.js +1 -1
  25. package/lib/core/AxiosHeaders.js +102 -80
  26. package/lib/core/dispatchRequest.js +7 -2
  27. package/lib/core/mergeConfig.js +50 -46
  28. package/lib/defaults/index.js +2 -21
  29. package/lib/env/classes/FormData.js +2 -2
  30. package/lib/env/data.js +1 -1
  31. package/lib/helpers/HttpStatusCode.js +71 -0
  32. package/lib/helpers/ZlibHeaderTransformStream.js +28 -0
  33. package/lib/helpers/formDataToStream.js +111 -0
  34. package/lib/helpers/readBlob.js +15 -0
  35. package/lib/helpers/speedometer.js +1 -1
  36. package/lib/helpers/toFormData.js +5 -15
  37. package/lib/platform/browser/classes/Blob.js +3 -0
  38. package/lib/platform/browser/classes/FormData.js +1 -1
  39. package/lib/platform/browser/index.js +21 -0
  40. package/lib/utils.js +107 -9
  41. package/package.json +86 -14
  42. package/bin/ssl_hotfix.js +0 -22
  43. package/gulpfile.js +0 -88
  44. package/karma.conf.cjs +0 -250
  45. package/lib/adapters/index.js +0 -33
  46. package/rollup.config.js +0 -90
  47. package/tsconfig.json +0 -14
  48. package/tslint.json +0 -6
@@ -1,4 +1,4 @@
1
- // Axios v1.1.3 Copyright (c) 2022 Matt Zabriskie and contributors
1
+ // Axios v1.3.4 Copyright (c) 2023 Matt Zabriskie and contributors
2
2
  'use strict';
3
3
 
4
4
  const FormData$1 = require('form-data');
@@ -6,6 +6,7 @@ const url = require('url');
6
6
  const proxyFromEnv = require('proxy-from-env');
7
7
  const http = require('http');
8
8
  const https = require('https');
9
+ const util = require('util');
9
10
  const followRedirects = require('follow-redirects');
10
11
  const zlib = require('zlib');
11
12
  const stream = require('stream');
@@ -17,6 +18,7 @@ const FormData__default = /*#__PURE__*/_interopDefaultLegacy(FormData$1);
17
18
  const url__default = /*#__PURE__*/_interopDefaultLegacy(url);
18
19
  const http__default = /*#__PURE__*/_interopDefaultLegacy(http);
19
20
  const https__default = /*#__PURE__*/_interopDefaultLegacy(https);
21
+ const util__default = /*#__PURE__*/_interopDefaultLegacy(util);
20
22
  const followRedirects__default = /*#__PURE__*/_interopDefaultLegacy(followRedirects);
21
23
  const zlib__default = /*#__PURE__*/_interopDefaultLegacy(zlib);
22
24
  const stream__default = /*#__PURE__*/_interopDefaultLegacy(stream);
@@ -254,7 +256,7 @@ const trim = (str) => str.trim ?
254
256
  * @param {Function} fn The callback to invoke for each item
255
257
  *
256
258
  * @param {Boolean} [allOwnKeys = false]
257
- * @returns {void}
259
+ * @returns {any}
258
260
  */
259
261
  function forEach(obj, fn, {allOwnKeys = false} = {}) {
260
262
  // Don't bother if no value provided
@@ -289,6 +291,28 @@ function forEach(obj, fn, {allOwnKeys = false} = {}) {
289
291
  }
290
292
  }
291
293
 
294
+ function findKey(obj, key) {
295
+ key = key.toLowerCase();
296
+ const keys = Object.keys(obj);
297
+ let i = keys.length;
298
+ let _key;
299
+ while (i-- > 0) {
300
+ _key = keys[i];
301
+ if (key === _key.toLowerCase()) {
302
+ return _key;
303
+ }
304
+ }
305
+ return null;
306
+ }
307
+
308
+ const _global = (() => {
309
+ /*eslint no-undef:0*/
310
+ if (typeof globalThis !== "undefined") return globalThis;
311
+ return typeof self !== "undefined" ? self : (typeof window !== 'undefined' ? window : global)
312
+ })();
313
+
314
+ const isContextDefined = (context) => !isUndefined(context) && context !== _global;
315
+
292
316
  /**
293
317
  * Accepts varargs expecting each argument to be an object, then
294
318
  * immutably merges the properties of each object and returns result.
@@ -308,16 +332,18 @@ function forEach(obj, fn, {allOwnKeys = false} = {}) {
308
332
  * @returns {Object} Result of all merge properties
309
333
  */
310
334
  function merge(/* obj1, obj2, obj3, ... */) {
335
+ const {caseless} = isContextDefined(this) && this || {};
311
336
  const result = {};
312
337
  const assignValue = (val, key) => {
313
- if (isPlainObject(result[key]) && isPlainObject(val)) {
314
- result[key] = merge(result[key], val);
338
+ const targetKey = caseless && findKey(result, key) || key;
339
+ if (isPlainObject(result[targetKey]) && isPlainObject(val)) {
340
+ result[targetKey] = merge(result[targetKey], val);
315
341
  } else if (isPlainObject(val)) {
316
- result[key] = merge({}, val);
342
+ result[targetKey] = merge({}, val);
317
343
  } else if (isArray(val)) {
318
- result[key] = val.slice();
344
+ result[targetKey] = val.slice();
319
345
  } else {
320
- result[key] = val;
346
+ result[targetKey] = val;
321
347
  }
322
348
  };
323
349
 
@@ -514,7 +540,7 @@ const matchAll = (regExp, str) => {
514
540
  const isHTMLForm = kindOfTest('HTMLFormElement');
515
541
 
516
542
  const toCamelCase = str => {
517
- return str.toLowerCase().replace(/[_-\s]([a-z\d])(\w*)/g,
543
+ return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,
518
544
  function replacer(m, p1, p2) {
519
545
  return p1.toUpperCase() + p2;
520
546
  }
@@ -553,6 +579,11 @@ const reduceDescriptors = (obj, reducer) => {
553
579
 
554
580
  const freezeMethods = (obj) => {
555
581
  reduceDescriptors(obj, (descriptor, name) => {
582
+ // skip restricted props in strict mode
583
+ if (isFunction(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
584
+ return false;
585
+ }
586
+
556
587
  const value = obj[name];
557
588
 
558
589
  if (!isFunction(value)) return;
@@ -566,7 +597,7 @@ const freezeMethods = (obj) => {
566
597
 
567
598
  if (!descriptor.set) {
568
599
  descriptor.set = () => {
569
- throw Error('Can not read-only method \'' + name + '\'');
600
+ throw Error('Can not rewrite read-only method \'' + name + '\'');
570
601
  };
571
602
  }
572
603
  });
@@ -593,6 +624,68 @@ const toFiniteNumber = (value, defaultValue) => {
593
624
  return Number.isFinite(value) ? value : defaultValue;
594
625
  };
595
626
 
627
+ const ALPHA = 'abcdefghijklmnopqrstuvwxyz';
628
+
629
+ const DIGIT = '0123456789';
630
+
631
+ const ALPHABET = {
632
+ DIGIT,
633
+ ALPHA,
634
+ ALPHA_DIGIT: ALPHA + ALPHA.toUpperCase() + DIGIT
635
+ };
636
+
637
+ const generateString = (size = 16, alphabet = ALPHABET.ALPHA_DIGIT) => {
638
+ let str = '';
639
+ const {length} = alphabet;
640
+ while (size--) {
641
+ str += alphabet[Math.random() * length|0];
642
+ }
643
+
644
+ return str;
645
+ };
646
+
647
+ /**
648
+ * If the thing is a FormData object, return true, otherwise return false.
649
+ *
650
+ * @param {unknown} thing - The thing to check.
651
+ *
652
+ * @returns {boolean}
653
+ */
654
+ function isSpecCompliantForm(thing) {
655
+ return !!(thing && isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator]);
656
+ }
657
+
658
+ const toJSONObject = (obj) => {
659
+ const stack = new Array(10);
660
+
661
+ const visit = (source, i) => {
662
+
663
+ if (isObject(source)) {
664
+ if (stack.indexOf(source) >= 0) {
665
+ return;
666
+ }
667
+
668
+ if(!('toJSON' in source)) {
669
+ stack[i] = source;
670
+ const target = isArray(source) ? [] : {};
671
+
672
+ forEach(source, (value, key) => {
673
+ const reducedValue = visit(value, i + 1);
674
+ !isUndefined(reducedValue) && (target[key] = reducedValue);
675
+ });
676
+
677
+ stack[i] = undefined;
678
+
679
+ return target;
680
+ }
681
+ }
682
+
683
+ return source;
684
+ };
685
+
686
+ return visit(obj, 0);
687
+ };
688
+
596
689
  const utils = {
597
690
  isArray,
598
691
  isArrayBuffer,
@@ -635,7 +728,14 @@ const utils = {
635
728
  toObjectSet,
636
729
  toCamelCase,
637
730
  noop,
638
- toFiniteNumber
731
+ toFiniteNumber,
732
+ findKey,
733
+ global: _global,
734
+ isContextDefined,
735
+ ALPHABET,
736
+ generateString,
737
+ isSpecCompliantForm,
738
+ toJSONObject
639
739
  };
640
740
 
641
741
  /**
@@ -681,7 +781,7 @@ utils.inherits(AxiosError, Error, {
681
781
  columnNumber: this.columnNumber,
682
782
  stack: this.stack,
683
783
  // Axios
684
- config: this.config,
784
+ config: utils.toJSONObject(this.config),
685
785
  code: this.code,
686
786
  status: this.response && this.response.status ? this.response.status : null
687
787
  };
@@ -788,17 +888,6 @@ const predicates = utils.toFlatObject(utils, {}, null, function filter(prop) {
788
888
  return /^is[A-Z]/.test(prop);
789
889
  });
790
890
 
791
- /**
792
- * If the thing is a FormData object, return true, otherwise return false.
793
- *
794
- * @param {unknown} thing - The thing to check.
795
- *
796
- * @returns {boolean}
797
- */
798
- function isSpecCompliant(thing) {
799
- return thing && utils.isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator];
800
- }
801
-
802
891
  /**
803
892
  * Convert a data object to FormData
804
893
  *
@@ -846,7 +935,7 @@ function toFormData(obj, formData, options) {
846
935
  const dots = options.dots;
847
936
  const indexes = options.indexes;
848
937
  const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
849
- const useBlob = _Blob && isSpecCompliant(formData);
938
+ const useBlob = _Blob && utils.isSpecCompliantForm(formData);
850
939
 
851
940
  if (!utils.isFunction(visitor)) {
852
941
  throw new TypeError('visitor must be a function');
@@ -891,7 +980,7 @@ function toFormData(obj, formData, options) {
891
980
  value = JSON.stringify(value);
892
981
  } else if (
893
982
  (utils.isArray(value) && isFlatArray(value)) ||
894
- (utils.isFileList(value) || utils.endsWith(key, '[]') && (arr = utils.toArray(value))
983
+ ((utils.isFileList(value) || utils.endsWith(key, '[]')) && (arr = utils.toArray(value))
895
984
  )) {
896
985
  // eslint-disable-next-line no-param-reassign
897
986
  key = removeBrackets(key);
@@ -1133,6 +1222,8 @@ class InterceptorManager {
1133
1222
  }
1134
1223
  }
1135
1224
 
1225
+ const InterceptorManager$1 = InterceptorManager;
1226
+
1136
1227
  const transitionalDefaults = {
1137
1228
  silentJSONParsing: true,
1138
1229
  forcedJSONParsing: true,
@@ -1251,157 +1342,171 @@ function formDataToJSON(formData) {
1251
1342
  return null;
1252
1343
  }
1253
1344
 
1254
- /**
1255
- * Resolve or reject a Promise based on response status.
1256
- *
1257
- * @param {Function} resolve A function that resolves the promise.
1258
- * @param {Function} reject A function that rejects the promise.
1259
- * @param {object} response The response.
1260
- *
1261
- * @returns {object} The response.
1262
- */
1263
- function settle(resolve, reject, response) {
1264
- const validateStatus = response.config.validateStatus;
1265
- if (!response.status || !validateStatus || validateStatus(response.status)) {
1266
- resolve(response);
1267
- } else {
1268
- reject(new AxiosError(
1269
- 'Request failed with status code ' + response.status,
1270
- [AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
1271
- response.config,
1272
- response.request,
1273
- response
1274
- ));
1275
- }
1276
- }
1277
-
1278
- /**
1279
- * Determines whether the specified URL is absolute
1280
- *
1281
- * @param {string} url The URL to test
1282
- *
1283
- * @returns {boolean} True if the specified URL is absolute, otherwise false
1284
- */
1285
- function isAbsoluteURL(url) {
1286
- // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
1287
- // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
1288
- // by any combination of letters, digits, plus, period, or hyphen.
1289
- return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
1290
- }
1291
-
1292
- /**
1293
- * Creates a new URL by combining the specified URLs
1294
- *
1295
- * @param {string} baseURL The base URL
1296
- * @param {string} relativeURL The relative URL
1297
- *
1298
- * @returns {string} The combined URL
1299
- */
1300
- function combineURLs(baseURL, relativeURL) {
1301
- return relativeURL
1302
- ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
1303
- : baseURL;
1304
- }
1345
+ const DEFAULT_CONTENT_TYPE = {
1346
+ 'Content-Type': undefined
1347
+ };
1305
1348
 
1306
1349
  /**
1307
- * Creates a new URL by combining the baseURL with the requestedURL,
1308
- * only when the requestedURL is not already an absolute URL.
1309
- * If the requestURL is absolute, this function returns the requestedURL untouched.
1350
+ * It takes a string, tries to parse it, and if it fails, it returns the stringified version
1351
+ * of the input
1310
1352
  *
1311
- * @param {string} baseURL The base URL
1312
- * @param {string} requestedURL Absolute or relative URL to combine
1353
+ * @param {any} rawValue - The value to be stringified.
1354
+ * @param {Function} parser - A function that parses a string into a JavaScript object.
1355
+ * @param {Function} encoder - A function that takes a value and returns a string.
1313
1356
  *
1314
- * @returns {string} The combined full path
1357
+ * @returns {string} A stringified version of the rawValue.
1315
1358
  */
1316
- function buildFullPath(baseURL, requestedURL) {
1317
- if (baseURL && !isAbsoluteURL(requestedURL)) {
1318
- return combineURLs(baseURL, requestedURL);
1359
+ function stringifySafely(rawValue, parser, encoder) {
1360
+ if (utils.isString(rawValue)) {
1361
+ try {
1362
+ (parser || JSON.parse)(rawValue);
1363
+ return utils.trim(rawValue);
1364
+ } catch (e) {
1365
+ if (e.name !== 'SyntaxError') {
1366
+ throw e;
1367
+ }
1368
+ }
1319
1369
  }
1320
- return requestedURL;
1321
- }
1322
-
1323
- const VERSION = "1.1.3";
1324
1370
 
1325
- /**
1326
- * A `CanceledError` is an object that is thrown when an operation is canceled.
1327
- *
1328
- * @param {string=} message The message.
1329
- * @param {Object=} config The config.
1330
- * @param {Object=} request The request.
1331
- *
1332
- * @returns {CanceledError} The created error.
1333
- */
1334
- function CanceledError(message, config, request) {
1335
- // eslint-disable-next-line no-eq-null,eqeqeq
1336
- AxiosError.call(this, message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request);
1337
- this.name = 'CanceledError';
1371
+ return (encoder || JSON.stringify)(rawValue);
1338
1372
  }
1339
1373
 
1340
- utils.inherits(CanceledError, AxiosError, {
1341
- __CANCEL__: true
1342
- });
1374
+ const defaults = {
1343
1375
 
1344
- function parseProtocol(url) {
1345
- const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
1346
- return match && match[1] || '';
1347
- }
1376
+ transitional: transitionalDefaults,
1348
1377
 
1349
- const DATA_URL_PATTERN = /^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;
1378
+ adapter: ['xhr', 'http'],
1350
1379
 
1351
- /**
1352
- * Parse data uri to a Buffer or Blob
1353
- *
1354
- * @param {String} uri
1355
- * @param {?Boolean} asBlob
1356
- * @param {?Object} options
1357
- * @param {?Function} options.Blob
1358
- *
1359
- * @returns {Buffer|Blob}
1360
- */
1361
- function fromDataURI(uri, asBlob, options) {
1362
- const _Blob = options && options.Blob || platform.classes.Blob;
1363
- const protocol = parseProtocol(uri);
1380
+ transformRequest: [function transformRequest(data, headers) {
1381
+ const contentType = headers.getContentType() || '';
1382
+ const hasJSONContentType = contentType.indexOf('application/json') > -1;
1383
+ const isObjectPayload = utils.isObject(data);
1364
1384
 
1365
- if (asBlob === undefined && _Blob) {
1366
- asBlob = true;
1367
- }
1385
+ if (isObjectPayload && utils.isHTMLForm(data)) {
1386
+ data = new FormData(data);
1387
+ }
1368
1388
 
1369
- if (protocol === 'data') {
1370
- uri = protocol.length ? uri.slice(protocol.length + 1) : uri;
1389
+ const isFormData = utils.isFormData(data);
1371
1390
 
1372
- const match = DATA_URL_PATTERN.exec(uri);
1391
+ if (isFormData) {
1392
+ if (!hasJSONContentType) {
1393
+ return data;
1394
+ }
1395
+ return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
1396
+ }
1373
1397
 
1374
- if (!match) {
1375
- throw new AxiosError('Invalid URL', AxiosError.ERR_INVALID_URL);
1398
+ if (utils.isArrayBuffer(data) ||
1399
+ utils.isBuffer(data) ||
1400
+ utils.isStream(data) ||
1401
+ utils.isFile(data) ||
1402
+ utils.isBlob(data)
1403
+ ) {
1404
+ return data;
1405
+ }
1406
+ if (utils.isArrayBufferView(data)) {
1407
+ return data.buffer;
1408
+ }
1409
+ if (utils.isURLSearchParams(data)) {
1410
+ headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
1411
+ return data.toString();
1376
1412
  }
1377
1413
 
1378
- const mime = match[1];
1379
- const isBase64 = match[2];
1380
- const body = match[3];
1381
- const buffer = Buffer.from(decodeURIComponent(body), isBase64 ? 'base64' : 'utf8');
1414
+ let isFileList;
1382
1415
 
1383
- if (asBlob) {
1384
- if (!_Blob) {
1385
- throw new AxiosError('Blob is not supported', AxiosError.ERR_NOT_SUPPORT);
1416
+ if (isObjectPayload) {
1417
+ if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
1418
+ return toURLEncodedForm(data, this.formSerializer).toString();
1386
1419
  }
1387
1420
 
1388
- return new _Blob([buffer], {type: mime});
1421
+ if ((isFileList = utils.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
1422
+ const _FormData = this.env && this.env.FormData;
1423
+
1424
+ return toFormData(
1425
+ isFileList ? {'files[]': data} : data,
1426
+ _FormData && new _FormData(),
1427
+ this.formSerializer
1428
+ );
1429
+ }
1389
1430
  }
1390
1431
 
1391
- return buffer;
1392
- }
1432
+ if (isObjectPayload || hasJSONContentType ) {
1433
+ headers.setContentType('application/json', false);
1434
+ return stringifySafely(data);
1435
+ }
1393
1436
 
1394
- throw new AxiosError('Unsupported protocol ' + protocol, AxiosError.ERR_NOT_SUPPORT);
1395
- }
1437
+ return data;
1438
+ }],
1396
1439
 
1397
- // RawAxiosHeaders whose duplicates are ignored by node
1398
- // c.f. https://nodejs.org/api/http.html#http_message_headers
1399
- const ignoreDuplicateOf = utils.toObjectSet([
1400
- 'age', 'authorization', 'content-length', 'content-type', 'etag',
1401
- 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
1402
- 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
1403
- 'referer', 'retry-after', 'user-agent'
1404
- ]);
1440
+ transformResponse: [function transformResponse(data) {
1441
+ const transitional = this.transitional || defaults.transitional;
1442
+ const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
1443
+ const JSONRequested = this.responseType === 'json';
1444
+
1445
+ if (data && utils.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
1446
+ const silentJSONParsing = transitional && transitional.silentJSONParsing;
1447
+ const strictJSONParsing = !silentJSONParsing && JSONRequested;
1448
+
1449
+ try {
1450
+ return JSON.parse(data);
1451
+ } catch (e) {
1452
+ if (strictJSONParsing) {
1453
+ if (e.name === 'SyntaxError') {
1454
+ throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response);
1455
+ }
1456
+ throw e;
1457
+ }
1458
+ }
1459
+ }
1460
+
1461
+ return data;
1462
+ }],
1463
+
1464
+ /**
1465
+ * A timeout in milliseconds to abort a request. If set to 0 (default) a
1466
+ * timeout is not created.
1467
+ */
1468
+ timeout: 0,
1469
+
1470
+ xsrfCookieName: 'XSRF-TOKEN',
1471
+ xsrfHeaderName: 'X-XSRF-TOKEN',
1472
+
1473
+ maxContentLength: -1,
1474
+ maxBodyLength: -1,
1475
+
1476
+ env: {
1477
+ FormData: platform.classes.FormData,
1478
+ Blob: platform.classes.Blob
1479
+ },
1480
+
1481
+ validateStatus: function validateStatus(status) {
1482
+ return status >= 200 && status < 300;
1483
+ },
1484
+
1485
+ headers: {
1486
+ common: {
1487
+ 'Accept': 'application/json, text/plain, */*'
1488
+ }
1489
+ }
1490
+ };
1491
+
1492
+ utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
1493
+ defaults.headers[method] = {};
1494
+ });
1495
+
1496
+ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
1497
+ defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
1498
+ });
1499
+
1500
+ const defaults$1 = defaults;
1501
+
1502
+ // RawAxiosHeaders whose duplicates are ignored by node
1503
+ // c.f. https://nodejs.org/api/http.html#http_message_headers
1504
+ const ignoreDuplicateOf = utils.toObjectSet([
1505
+ 'age', 'authorization', 'content-length', 'content-type', 'etag',
1506
+ 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
1507
+ 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
1508
+ 'referer', 'retry-after', 'user-agent'
1509
+ ]);
1405
1510
 
1406
1511
  /**
1407
1512
  * Parse headers into an object
@@ -1447,7 +1552,6 @@ const parseHeaders = rawHeaders => {
1447
1552
  };
1448
1553
 
1449
1554
  const $internals = Symbol('internals');
1450
- const $defaults = Symbol('defaults');
1451
1555
 
1452
1556
  function normalizeHeader(header) {
1453
1557
  return header && String(header).trim().toLowerCase();
@@ -1473,11 +1577,19 @@ function parseTokens(str) {
1473
1577
  return tokens;
1474
1578
  }
1475
1579
 
1476
- function matchHeaderValue(context, value, header, filter) {
1580
+ function isValidHeaderName(str) {
1581
+ return /^[-_a-zA-Z]+$/.test(str.trim());
1582
+ }
1583
+
1584
+ function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
1477
1585
  if (utils.isFunction(filter)) {
1478
1586
  return filter.call(this, value, header);
1479
1587
  }
1480
1588
 
1589
+ if (isHeaderNameFilter) {
1590
+ value = header;
1591
+ }
1592
+
1481
1593
  if (!utils.isString(value)) return;
1482
1594
 
1483
1595
  if (utils.isString(filter)) {
@@ -1509,27 +1621,12 @@ function buildAccessors(obj, header) {
1509
1621
  });
1510
1622
  }
1511
1623
 
1512
- function findKey(obj, key) {
1513
- key = key.toLowerCase();
1514
- const keys = Object.keys(obj);
1515
- let i = keys.length;
1516
- let _key;
1517
- while (i-- > 0) {
1518
- _key = keys[i];
1519
- if (key === _key.toLowerCase()) {
1520
- return _key;
1521
- }
1624
+ class AxiosHeaders {
1625
+ constructor(headers) {
1626
+ headers && this.set(headers);
1522
1627
  }
1523
- return null;
1524
- }
1525
-
1526
- function AxiosHeaders(headers, defaults) {
1527
- headers && this.set(headers);
1528
- this[$defaults] = defaults || null;
1529
- }
1530
1628
 
1531
- Object.assign(AxiosHeaders.prototype, {
1532
- set: function(header, valueOrRewrite, rewrite) {
1629
+ set(header, valueOrRewrite, rewrite) {
1533
1630
  const self = this;
1534
1631
 
1535
1632
  function setHeader(_value, _header, _rewrite) {
@@ -1539,69 +1636,70 @@ Object.assign(AxiosHeaders.prototype, {
1539
1636
  throw new Error('header name must be a non-empty string');
1540
1637
  }
1541
1638
 
1542
- const key = findKey(self, lHeader);
1639
+ const key = utils.findKey(self, lHeader);
1543
1640
 
1544
- if (key && _rewrite !== true && (self[key] === false || _rewrite === false)) {
1545
- return;
1641
+ if(!key || self[key] === undefined || _rewrite === true || (_rewrite === undefined && self[key] !== false)) {
1642
+ self[key || _header] = normalizeValue(_value);
1546
1643
  }
1547
-
1548
- self[key || _header] = normalizeValue(_value);
1549
1644
  }
1550
1645
 
1551
- if (utils.isPlainObject(header)) {
1552
- utils.forEach(header, (_value, _header) => {
1553
- setHeader(_value, _header, valueOrRewrite);
1554
- });
1646
+ const setHeaders = (headers, _rewrite) =>
1647
+ utils.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
1648
+
1649
+ if (utils.isPlainObject(header) || header instanceof this.constructor) {
1650
+ setHeaders(header, valueOrRewrite);
1651
+ } else if(utils.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
1652
+ setHeaders(parseHeaders(header), valueOrRewrite);
1555
1653
  } else {
1556
- setHeader(valueOrRewrite, header, rewrite);
1654
+ header != null && setHeader(valueOrRewrite, header, rewrite);
1557
1655
  }
1558
1656
 
1559
1657
  return this;
1560
- },
1658
+ }
1561
1659
 
1562
- get: function(header, parser) {
1660
+ get(header, parser) {
1563
1661
  header = normalizeHeader(header);
1564
1662
 
1565
- if (!header) return undefined;
1663
+ if (header) {
1664
+ const key = utils.findKey(this, header);
1566
1665
 
1567
- const key = findKey(this, header);
1666
+ if (key) {
1667
+ const value = this[key];
1568
1668
 
1569
- if (key) {
1570
- const value = this[key];
1669
+ if (!parser) {
1670
+ return value;
1671
+ }
1571
1672
 
1572
- if (!parser) {
1573
- return value;
1574
- }
1673
+ if (parser === true) {
1674
+ return parseTokens(value);
1675
+ }
1575
1676
 
1576
- if (parser === true) {
1577
- return parseTokens(value);
1578
- }
1677
+ if (utils.isFunction(parser)) {
1678
+ return parser.call(this, value, key);
1679
+ }
1579
1680
 
1580
- if (utils.isFunction(parser)) {
1581
- return parser.call(this, value, key);
1582
- }
1681
+ if (utils.isRegExp(parser)) {
1682
+ return parser.exec(value);
1683
+ }
1583
1684
 
1584
- if (utils.isRegExp(parser)) {
1585
- return parser.exec(value);
1685
+ throw new TypeError('parser must be boolean|regexp|function');
1586
1686
  }
1587
-
1588
- throw new TypeError('parser must be boolean|regexp|function');
1589
1687
  }
1590
- },
1688
+ }
1591
1689
 
1592
- has: function(header, matcher) {
1690
+ has(header, matcher) {
1593
1691
  header = normalizeHeader(header);
1594
1692
 
1595
1693
  if (header) {
1596
- const key = findKey(this, header);
1694
+ const key = utils.findKey(this, header);
1597
1695
 
1598
- return !!(key && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
1696
+ return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
1599
1697
  }
1600
1698
 
1601
1699
  return false;
1602
- },
1700
+ }
1603
1701
 
1604
- delete: function(header, matcher) {
1702
+ delete(header, matcher) {
1605
1703
  const self = this;
1606
1704
  let deleted = false;
1607
1705
 
@@ -1609,7 +1707,7 @@ Object.assign(AxiosHeaders.prototype, {
1609
1707
  _header = normalizeHeader(_header);
1610
1708
 
1611
1709
  if (_header) {
1612
- const key = findKey(self, _header);
1710
+ const key = utils.findKey(self, _header);
1613
1711
 
1614
1712
  if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
1615
1713
  delete self[key];
@@ -1626,18 +1724,30 @@ Object.assign(AxiosHeaders.prototype, {
1626
1724
  }
1627
1725
 
1628
1726
  return deleted;
1629
- },
1727
+ }
1630
1728
 
1631
- clear: function() {
1632
- return Object.keys(this).forEach(this.delete.bind(this));
1633
- },
1729
+ clear(matcher) {
1730
+ const keys = Object.keys(this);
1731
+ let i = keys.length;
1732
+ let deleted = false;
1634
1733
 
1635
- normalize: function(format) {
1734
+ while (i--) {
1735
+ const key = keys[i];
1736
+ if(!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
1737
+ delete this[key];
1738
+ deleted = true;
1739
+ }
1740
+ }
1741
+
1742
+ return deleted;
1743
+ }
1744
+
1745
+ normalize(format) {
1636
1746
  const self = this;
1637
1747
  const headers = {};
1638
1748
 
1639
1749
  utils.forEach(this, (value, header) => {
1640
- const key = findKey(headers, header);
1750
+ const key = utils.findKey(headers, header);
1641
1751
 
1642
1752
  if (key) {
1643
1753
  self[key] = normalizeValue(value);
@@ -1657,30 +1767,47 @@ Object.assign(AxiosHeaders.prototype, {
1657
1767
  });
1658
1768
 
1659
1769
  return this;
1660
- },
1770
+ }
1771
+
1772
+ concat(...targets) {
1773
+ return this.constructor.concat(this, ...targets);
1774
+ }
1661
1775
 
1662
- toJSON: function(asStrings) {
1776
+ toJSON(asStrings) {
1663
1777
  const obj = Object.create(null);
1664
1778
 
1665
- utils.forEach(Object.assign({}, this[$defaults] || null, this),
1666
- (value, header) => {
1667
- if (value == null || value === false) return;
1668
- obj[header] = asStrings && utils.isArray(value) ? value.join(', ') : value;
1669
- });
1779
+ utils.forEach(this, (value, header) => {
1780
+ value != null && value !== false && (obj[header] = asStrings && utils.isArray(value) ? value.join(', ') : value);
1781
+ });
1670
1782
 
1671
1783
  return obj;
1672
1784
  }
1673
- });
1674
1785
 
1675
- Object.assign(AxiosHeaders, {
1676
- from: function(thing) {
1677
- if (utils.isString(thing)) {
1678
- return new this(parseHeaders(thing));
1679
- }
1786
+ [Symbol.iterator]() {
1787
+ return Object.entries(this.toJSON())[Symbol.iterator]();
1788
+ }
1789
+
1790
+ toString() {
1791
+ return Object.entries(this.toJSON()).map(([header, value]) => header + ': ' + value).join('\n');
1792
+ }
1793
+
1794
+ get [Symbol.toStringTag]() {
1795
+ return 'AxiosHeaders';
1796
+ }
1797
+
1798
+ static from(thing) {
1680
1799
  return thing instanceof this ? thing : new this(thing);
1681
- },
1800
+ }
1801
+
1802
+ static concat(first, ...targets) {
1803
+ const computed = new this(first);
1682
1804
 
1683
- accessor: function(header) {
1805
+ targets.forEach((target) => computed.set(target));
1806
+
1807
+ return computed;
1808
+ }
1809
+
1810
+ static accessor(header) {
1684
1811
  const internals = this[$internals] = (this[$internals] = {
1685
1812
  accessors: {}
1686
1813
  });
@@ -1701,13 +1828,185 @@ Object.assign(AxiosHeaders, {
1701
1828
 
1702
1829
  return this;
1703
1830
  }
1704
- });
1831
+ }
1705
1832
 
1706
- AxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent']);
1833
+ AxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
1707
1834
 
1708
1835
  utils.freezeMethods(AxiosHeaders.prototype);
1709
1836
  utils.freezeMethods(AxiosHeaders);
1710
1837
 
1838
+ const AxiosHeaders$1 = AxiosHeaders;
1839
+
1840
+ /**
1841
+ * Transform the data for a request or a response
1842
+ *
1843
+ * @param {Array|Function} fns A single function or Array of functions
1844
+ * @param {?Object} response The response object
1845
+ *
1846
+ * @returns {*} The resulting transformed data
1847
+ */
1848
+ function transformData(fns, response) {
1849
+ const config = this || defaults$1;
1850
+ const context = response || config;
1851
+ const headers = AxiosHeaders$1.from(context.headers);
1852
+ let data = context.data;
1853
+
1854
+ utils.forEach(fns, function transform(fn) {
1855
+ data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
1856
+ });
1857
+
1858
+ headers.normalize();
1859
+
1860
+ return data;
1861
+ }
1862
+
1863
+ function isCancel(value) {
1864
+ return !!(value && value.__CANCEL__);
1865
+ }
1866
+
1867
+ /**
1868
+ * A `CanceledError` is an object that is thrown when an operation is canceled.
1869
+ *
1870
+ * @param {string=} message The message.
1871
+ * @param {Object=} config The config.
1872
+ * @param {Object=} request The request.
1873
+ *
1874
+ * @returns {CanceledError} The created error.
1875
+ */
1876
+ function CanceledError(message, config, request) {
1877
+ // eslint-disable-next-line no-eq-null,eqeqeq
1878
+ AxiosError.call(this, message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request);
1879
+ this.name = 'CanceledError';
1880
+ }
1881
+
1882
+ utils.inherits(CanceledError, AxiosError, {
1883
+ __CANCEL__: true
1884
+ });
1885
+
1886
+ /**
1887
+ * Resolve or reject a Promise based on response status.
1888
+ *
1889
+ * @param {Function} resolve A function that resolves the promise.
1890
+ * @param {Function} reject A function that rejects the promise.
1891
+ * @param {object} response The response.
1892
+ *
1893
+ * @returns {object} The response.
1894
+ */
1895
+ function settle(resolve, reject, response) {
1896
+ const validateStatus = response.config.validateStatus;
1897
+ if (!response.status || !validateStatus || validateStatus(response.status)) {
1898
+ resolve(response);
1899
+ } else {
1900
+ reject(new AxiosError(
1901
+ 'Request failed with status code ' + response.status,
1902
+ [AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
1903
+ response.config,
1904
+ response.request,
1905
+ response
1906
+ ));
1907
+ }
1908
+ }
1909
+
1910
+ /**
1911
+ * Determines whether the specified URL is absolute
1912
+ *
1913
+ * @param {string} url The URL to test
1914
+ *
1915
+ * @returns {boolean} True if the specified URL is absolute, otherwise false
1916
+ */
1917
+ function isAbsoluteURL(url) {
1918
+ // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
1919
+ // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
1920
+ // by any combination of letters, digits, plus, period, or hyphen.
1921
+ return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
1922
+ }
1923
+
1924
+ /**
1925
+ * Creates a new URL by combining the specified URLs
1926
+ *
1927
+ * @param {string} baseURL The base URL
1928
+ * @param {string} relativeURL The relative URL
1929
+ *
1930
+ * @returns {string} The combined URL
1931
+ */
1932
+ function combineURLs(baseURL, relativeURL) {
1933
+ return relativeURL
1934
+ ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
1935
+ : baseURL;
1936
+ }
1937
+
1938
+ /**
1939
+ * Creates a new URL by combining the baseURL with the requestedURL,
1940
+ * only when the requestedURL is not already an absolute URL.
1941
+ * If the requestURL is absolute, this function returns the requestedURL untouched.
1942
+ *
1943
+ * @param {string} baseURL The base URL
1944
+ * @param {string} requestedURL Absolute or relative URL to combine
1945
+ *
1946
+ * @returns {string} The combined full path
1947
+ */
1948
+ function buildFullPath(baseURL, requestedURL) {
1949
+ if (baseURL && !isAbsoluteURL(requestedURL)) {
1950
+ return combineURLs(baseURL, requestedURL);
1951
+ }
1952
+ return requestedURL;
1953
+ }
1954
+
1955
+ const VERSION = "1.3.4";
1956
+
1957
+ function parseProtocol(url) {
1958
+ const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
1959
+ return match && match[1] || '';
1960
+ }
1961
+
1962
+ const DATA_URL_PATTERN = /^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;
1963
+
1964
+ /**
1965
+ * Parse data uri to a Buffer or Blob
1966
+ *
1967
+ * @param {String} uri
1968
+ * @param {?Boolean} asBlob
1969
+ * @param {?Object} options
1970
+ * @param {?Function} options.Blob
1971
+ *
1972
+ * @returns {Buffer|Blob}
1973
+ */
1974
+ function fromDataURI(uri, asBlob, options) {
1975
+ const _Blob = options && options.Blob || platform.classes.Blob;
1976
+ const protocol = parseProtocol(uri);
1977
+
1978
+ if (asBlob === undefined && _Blob) {
1979
+ asBlob = true;
1980
+ }
1981
+
1982
+ if (protocol === 'data') {
1983
+ uri = protocol.length ? uri.slice(protocol.length + 1) : uri;
1984
+
1985
+ const match = DATA_URL_PATTERN.exec(uri);
1986
+
1987
+ if (!match) {
1988
+ throw new AxiosError('Invalid URL', AxiosError.ERR_INVALID_URL);
1989
+ }
1990
+
1991
+ const mime = match[1];
1992
+ const isBase64 = match[2];
1993
+ const body = match[3];
1994
+ const buffer = Buffer.from(decodeURIComponent(body), isBase64 ? 'base64' : 'utf8');
1995
+
1996
+ if (asBlob) {
1997
+ if (!_Blob) {
1998
+ throw new AxiosError('Blob is not supported', AxiosError.ERR_NOT_SUPPORT);
1999
+ }
2000
+
2001
+ return new _Blob([buffer], {type: mime});
2002
+ }
2003
+
2004
+ return buffer;
2005
+ }
2006
+
2007
+ throw new AxiosError('Unsupported protocol ' + protocol, AxiosError.ERR_NOT_SUPPORT);
2008
+ }
2009
+
1711
2010
  /**
1712
2011
  * Throttle decorator
1713
2012
  * @param {Function} fn
@@ -1786,7 +2085,7 @@ function speedometer(samplesCount, min) {
1786
2085
 
1787
2086
  const passed = startedAt && now - startedAt;
1788
2087
 
1789
- return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
2088
+ return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
1790
2089
  };
1791
2090
  }
1792
2091
 
@@ -1973,6 +2272,166 @@ class AxiosTransformStream extends stream__default["default"].Transform{
1973
2272
  }
1974
2273
  }
1975
2274
 
2275
+ const AxiosTransformStream$1 = AxiosTransformStream;
2276
+
2277
+ const {asyncIterator} = Symbol;
2278
+
2279
+ const readBlob = async function* (blob) {
2280
+ if (blob.stream) {
2281
+ yield* blob.stream();
2282
+ } else if (blob.arrayBuffer) {
2283
+ yield await blob.arrayBuffer();
2284
+ } else if (blob[asyncIterator]) {
2285
+ yield* blob[asyncIterator]();
2286
+ } else {
2287
+ yield blob;
2288
+ }
2289
+ };
2290
+
2291
+ const readBlob$1 = readBlob;
2292
+
2293
+ const BOUNDARY_ALPHABET = utils.ALPHABET.ALPHA_DIGIT + '-_';
2294
+
2295
+ const textEncoder = new util.TextEncoder();
2296
+
2297
+ const CRLF = '\r\n';
2298
+ const CRLF_BYTES = textEncoder.encode(CRLF);
2299
+ const CRLF_BYTES_COUNT = 2;
2300
+
2301
+ class FormDataPart {
2302
+ constructor(name, value) {
2303
+ const {escapeName} = this.constructor;
2304
+ const isStringValue = utils.isString(value);
2305
+
2306
+ let headers = `Content-Disposition: form-data; name="${escapeName(name)}"${
2307
+ !isStringValue && value.name ? `; filename="${escapeName(value.name)}"` : ''
2308
+ }${CRLF}`;
2309
+
2310
+ if (isStringValue) {
2311
+ value = textEncoder.encode(String(value).replace(/\r?\n|\r\n?/g, CRLF));
2312
+ } else {
2313
+ headers += `Content-Type: ${value.type || "application/octet-stream"}${CRLF}`;
2314
+ }
2315
+
2316
+ this.headers = textEncoder.encode(headers + CRLF);
2317
+
2318
+ this.contentLength = isStringValue ? value.byteLength : value.size;
2319
+
2320
+ this.size = this.headers.byteLength + this.contentLength + CRLF_BYTES_COUNT;
2321
+
2322
+ this.name = name;
2323
+ this.value = value;
2324
+ }
2325
+
2326
+ async *encode(){
2327
+ yield this.headers;
2328
+
2329
+ const {value} = this;
2330
+
2331
+ if(utils.isTypedArray(value)) {
2332
+ yield value;
2333
+ } else {
2334
+ yield* readBlob$1(value);
2335
+ }
2336
+
2337
+ yield CRLF_BYTES;
2338
+ }
2339
+
2340
+ static escapeName(name) {
2341
+ return String(name).replace(/[\r\n"]/g, (match) => ({
2342
+ '\r' : '%0D',
2343
+ '\n' : '%0A',
2344
+ '"' : '%22',
2345
+ }[match]));
2346
+ }
2347
+ }
2348
+
2349
+ const formDataToStream = (form, headersHandler, options) => {
2350
+ const {
2351
+ tag = 'form-data-boundary',
2352
+ size = 25,
2353
+ boundary = tag + '-' + utils.generateString(size, BOUNDARY_ALPHABET)
2354
+ } = options || {};
2355
+
2356
+ if(!utils.isFormData(form)) {
2357
+ throw TypeError('FormData instance required');
2358
+ }
2359
+
2360
+ if (boundary.length < 1 || boundary.length > 70) {
2361
+ throw Error('boundary must be 10-70 characters long')
2362
+ }
2363
+
2364
+ const boundaryBytes = textEncoder.encode('--' + boundary + CRLF);
2365
+ const footerBytes = textEncoder.encode('--' + boundary + '--' + CRLF + CRLF);
2366
+ let contentLength = footerBytes.byteLength;
2367
+
2368
+ const parts = Array.from(form.entries()).map(([name, value]) => {
2369
+ const part = new FormDataPart(name, value);
2370
+ contentLength += part.size;
2371
+ return part;
2372
+ });
2373
+
2374
+ contentLength += boundaryBytes.byteLength * parts.length;
2375
+
2376
+ contentLength = utils.toFiniteNumber(contentLength);
2377
+
2378
+ const computedHeaders = {
2379
+ 'Content-Type': `multipart/form-data; boundary=${boundary}`
2380
+ };
2381
+
2382
+ if (Number.isFinite(contentLength)) {
2383
+ computedHeaders['Content-Length'] = contentLength;
2384
+ }
2385
+
2386
+ headersHandler && headersHandler(computedHeaders);
2387
+
2388
+ return stream.Readable.from((async function *() {
2389
+ for(const part of parts) {
2390
+ yield boundaryBytes;
2391
+ yield* part.encode();
2392
+ }
2393
+
2394
+ yield footerBytes;
2395
+ })());
2396
+ };
2397
+
2398
+ const formDataToStream$1 = formDataToStream;
2399
+
2400
+ class ZlibHeaderTransformStream extends stream__default["default"].Transform {
2401
+ __transform(chunk, encoding, callback) {
2402
+ this.push(chunk);
2403
+ callback();
2404
+ }
2405
+
2406
+ _transform(chunk, encoding, callback) {
2407
+ if (chunk.length !== 0) {
2408
+ this._transform = this.__transform;
2409
+
2410
+ // Add Default Compression headers if no zlib headers are present
2411
+ if (chunk[0] !== 120) { // Hex: 78
2412
+ const header = Buffer.alloc(2);
2413
+ header[0] = 120; // Hex: 78
2414
+ header[1] = 156; // Hex: 9C
2415
+ this.push(header, encoding);
2416
+ }
2417
+ }
2418
+
2419
+ this.__transform(chunk, encoding, callback);
2420
+ }
2421
+ }
2422
+
2423
+ const ZlibHeaderTransformStream$1 = ZlibHeaderTransformStream;
2424
+
2425
+ const zlibOptions = {
2426
+ flush: zlib__default["default"].constants.Z_SYNC_FLUSH,
2427
+ finishFlush: zlib__default["default"].constants.Z_SYNC_FLUSH
2428
+ };
2429
+
2430
+ const brotliOptions = {
2431
+ flush: zlib__default["default"].constants.BROTLI_OPERATION_FLUSH,
2432
+ finishFlush: zlib__default["default"].constants.BROTLI_OPERATION_FLUSH
2433
+ };
2434
+
1976
2435
  const isBrotliSupported = utils.isFunction(zlib__default["default"].createBrotliDecompress);
1977
2436
 
1978
2437
  const {http: httpFollow, https: httpsFollow} = followRedirects__default["default"];
@@ -2053,14 +2512,41 @@ function setProxy(options, configProxy, location) {
2053
2512
  };
2054
2513
  }
2055
2514
 
2515
+ const isHttpAdapterSupported = typeof process !== 'undefined' && utils.kindOf(process) === 'process';
2516
+
2517
+ // temporary hotfix
2518
+
2519
+ const wrapAsync = (asyncExecutor) => {
2520
+ return new Promise((resolve, reject) => {
2521
+ let onDone;
2522
+ let isDone;
2523
+
2524
+ const done = (value, isRejected) => {
2525
+ if (isDone) return;
2526
+ isDone = true;
2527
+ onDone && onDone(value, isRejected);
2528
+ };
2529
+
2530
+ const _resolve = (value) => {
2531
+ done(value);
2532
+ resolve(value);
2533
+ };
2534
+
2535
+ const _reject = (reason) => {
2536
+ done(reason, true);
2537
+ reject(reason);
2538
+ };
2539
+
2540
+ asyncExecutor(_resolve, _reject, (onDoneHandler) => (onDone = onDoneHandler)).catch(_reject);
2541
+ })
2542
+ };
2543
+
2056
2544
  /*eslint consistent-return:0*/
2057
- function httpAdapter(config) {
2058
- return new Promise(function dispatchHttpRequest(resolvePromise, rejectPromise) {
2059
- let data = config.data;
2060
- const responseType = config.responseType;
2061
- const responseEncoding = config.responseEncoding;
2545
+ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
2546
+ return wrapAsync(async function dispatchHttpRequest(resolve, reject, onDone) {
2547
+ let {data} = config;
2548
+ const {responseType, responseEncoding} = config;
2062
2549
  const method = config.method.toUpperCase();
2063
- let isFinished;
2064
2550
  let isDone;
2065
2551
  let rejected = false;
2066
2552
  let req;
@@ -2068,10 +2554,7 @@ function httpAdapter(config) {
2068
2554
  // temporary internal emitter until the AxiosRequest class will be implemented
2069
2555
  const emitter = new EventEmitter__default["default"]();
2070
2556
 
2071
- function onFinished() {
2072
- if (isFinished) return;
2073
- isFinished = true;
2074
-
2557
+ const onFinished = () => {
2075
2558
  if (config.cancelToken) {
2076
2559
  config.cancelToken.unsubscribe(abort);
2077
2560
  }
@@ -2081,28 +2564,15 @@ function httpAdapter(config) {
2081
2564
  }
2082
2565
 
2083
2566
  emitter.removeAllListeners();
2084
- }
2085
-
2086
- function done(value, isRejected) {
2087
- if (isDone) return;
2567
+ };
2088
2568
 
2569
+ onDone((value, isRejected) => {
2089
2570
  isDone = true;
2090
-
2091
2571
  if (isRejected) {
2092
2572
  rejected = true;
2093
2573
  onFinished();
2094
2574
  }
2095
-
2096
- isRejected ? rejectPromise(value) : resolvePromise(value);
2097
- }
2098
-
2099
- const resolve = function resolve(value) {
2100
- done(value);
2101
- };
2102
-
2103
- const reject = function reject(value) {
2104
- done(value, true);
2105
- };
2575
+ });
2106
2576
 
2107
2577
  function abort(reason) {
2108
2578
  emitter.emit('abort', !reason || reason.type ? new CanceledError(null, config, req) : reason);
@@ -2119,7 +2589,7 @@ function httpAdapter(config) {
2119
2589
 
2120
2590
  // Parse url
2121
2591
  const fullPath = buildFullPath(config.baseURL, config.url);
2122
- const parsed = new URL(fullPath);
2592
+ const parsed = new URL(fullPath, 'http://localhost');
2123
2593
  const protocol = parsed.protocol || supportedProtocols[0];
2124
2594
 
2125
2595
  if (protocol === 'data:') {
@@ -2146,7 +2616,7 @@ function httpAdapter(config) {
2146
2616
  convertedData = convertedData.toString(responseEncoding);
2147
2617
 
2148
2618
  if (!responseEncoding || responseEncoding === 'utf8') {
2149
- data = utils.stripBOM(convertedData);
2619
+ convertedData = utils.stripBOM(convertedData);
2150
2620
  }
2151
2621
  } else if (responseType === 'stream') {
2152
2622
  convertedData = stream__default["default"].Readable.from(convertedData);
@@ -2156,7 +2626,7 @@ function httpAdapter(config) {
2156
2626
  data: convertedData,
2157
2627
  status: 200,
2158
2628
  statusText: 'OK',
2159
- headers: {},
2629
+ headers: new AxiosHeaders$1(),
2160
2630
  config
2161
2631
  });
2162
2632
  }
@@ -2169,7 +2639,7 @@ function httpAdapter(config) {
2169
2639
  ));
2170
2640
  }
2171
2641
 
2172
- const headers = AxiosHeaders.from(config.headers).normalize();
2642
+ const headers = AxiosHeaders$1.from(config.headers).normalize();
2173
2643
 
2174
2644
  // Set User-Agent (required by some servers)
2175
2645
  // See https://github.com/axios/axios/issues/69
@@ -2183,9 +2653,32 @@ function httpAdapter(config) {
2183
2653
  let maxUploadRate = undefined;
2184
2654
  let maxDownloadRate = undefined;
2185
2655
 
2186
- // support for https://www.npmjs.com/package/form-data api
2187
- if (utils.isFormData(data) && utils.isFunction(data.getHeaders)) {
2656
+ // support for spec compliant FormData objects
2657
+ if (utils.isSpecCompliantForm(data)) {
2658
+ const userBoundary = headers.getContentType(/boundary=([-_\w\d]{10,70})/i);
2659
+
2660
+ data = formDataToStream$1(data, (formHeaders) => {
2661
+ headers.set(formHeaders);
2662
+ }, {
2663
+ tag: `axios-${VERSION}-boundary`,
2664
+ boundary: userBoundary && userBoundary[1] || undefined
2665
+ });
2666
+ // support for https://www.npmjs.com/package/form-data api
2667
+ } else if (utils.isFormData(data) && utils.isFunction(data.getHeaders)) {
2188
2668
  headers.set(data.getHeaders());
2669
+
2670
+ if (!headers.hasContentLength()) {
2671
+ try {
2672
+ const knownLength = await util__default["default"].promisify(data.getLength).call(data);
2673
+ Number.isFinite(knownLength) && knownLength >= 0 && headers.setContentLength(knownLength);
2674
+ /*eslint no-empty:0*/
2675
+ } catch (e) {
2676
+ }
2677
+ }
2678
+ } else if (utils.isBlob(data)) {
2679
+ data.size && headers.setContentType(data.type || 'application/octet-stream');
2680
+ headers.setContentLength(data.size || 0);
2681
+ data = stream__default["default"].Readable.from(readBlob$1(data));
2189
2682
  } else if (data && !utils.isStream(data)) {
2190
2683
  if (Buffer.isBuffer(data)) ; else if (utils.isArrayBuffer(data)) {
2191
2684
  data = Buffer.from(new Uint8Array(data));
@@ -2200,7 +2693,7 @@ function httpAdapter(config) {
2200
2693
  }
2201
2694
 
2202
2695
  // Add Content-Length header if data exists
2203
- headers.set('Content-Length', data.length, false);
2696
+ headers.setContentLength(data.length, false);
2204
2697
 
2205
2698
  if (config.maxBodyLength > -1 && data.length > config.maxBodyLength) {
2206
2699
  return reject(new AxiosError(
@@ -2211,7 +2704,7 @@ function httpAdapter(config) {
2211
2704
  }
2212
2705
  }
2213
2706
 
2214
- const contentLength = +headers.getContentLength();
2707
+ const contentLength = utils.toFiniteNumber(headers.getContentLength());
2215
2708
 
2216
2709
  if (utils.isArray(maxRate)) {
2217
2710
  maxUploadRate = maxRate[0];
@@ -2225,8 +2718,8 @@ function httpAdapter(config) {
2225
2718
  data = stream__default["default"].Readable.from(data, {objectMode: false});
2226
2719
  }
2227
2720
 
2228
- data = stream__default["default"].pipeline([data, new AxiosTransformStream({
2229
- length: utils.toFiniteNumber(contentLength),
2721
+ data = stream__default["default"].pipeline([data, new AxiosTransformStream$1({
2722
+ length: contentLength,
2230
2723
  maxRate: utils.toFiniteNumber(maxUploadRate)
2231
2724
  })], utils.noop);
2232
2725
 
@@ -2269,7 +2762,10 @@ function httpAdapter(config) {
2269
2762
  return reject(customErr);
2270
2763
  }
2271
2764
 
2272
- headers.set('Accept-Encoding', 'gzip, deflate, br', false);
2765
+ headers.set(
2766
+ 'Accept-Encoding',
2767
+ 'gzip, compress, deflate' + (isBrotliSupported ? ', br' : ''), false
2768
+ );
2273
2769
 
2274
2770
  const options = {
2275
2771
  path,
@@ -2324,56 +2820,66 @@ function httpAdapter(config) {
2324
2820
 
2325
2821
  const streams = [res];
2326
2822
 
2327
- // uncompress the response body transparently if required
2823
+ const responseLength = +res.headers['content-length'];
2824
+
2825
+ if (onDownloadProgress) {
2826
+ const transformStream = new AxiosTransformStream$1({
2827
+ length: utils.toFiniteNumber(responseLength),
2828
+ maxRate: utils.toFiniteNumber(maxDownloadRate)
2829
+ });
2830
+
2831
+ onDownloadProgress && transformStream.on('progress', progress => {
2832
+ onDownloadProgress(Object.assign(progress, {
2833
+ download: true
2834
+ }));
2835
+ });
2836
+
2837
+ streams.push(transformStream);
2838
+ }
2839
+
2840
+ // decompress the response body transparently if required
2328
2841
  let responseStream = res;
2329
2842
 
2330
2843
  // return the last request in case of redirects
2331
2844
  const lastRequest = res.req || req;
2332
2845
 
2333
2846
  // if decompress disabled we should not decompress
2334
- if (config.decompress !== false) {
2847
+ if (config.decompress !== false && res.headers['content-encoding']) {
2335
2848
  // if no content, but headers still say that it is encoded,
2336
2849
  // remove the header not confuse downstream operations
2337
- if (data && data.length === 0 && res.headers['content-encoding']) {
2850
+ if (method === 'HEAD' || res.statusCode === 204) {
2338
2851
  delete res.headers['content-encoding'];
2339
2852
  }
2340
2853
 
2341
2854
  switch (res.headers['content-encoding']) {
2342
2855
  /*eslint default-case:0*/
2343
2856
  case 'gzip':
2857
+ case 'x-gzip':
2344
2858
  case 'compress':
2859
+ case 'x-compress':
2860
+ // add the unzipper to the body stream processing pipeline
2861
+ streams.push(zlib__default["default"].createUnzip(zlibOptions));
2862
+
2863
+ // remove the content-encoding in order to not confuse downstream operations
2864
+ delete res.headers['content-encoding'];
2865
+ break;
2345
2866
  case 'deflate':
2867
+ streams.push(new ZlibHeaderTransformStream$1());
2868
+
2346
2869
  // add the unzipper to the body stream processing pipeline
2347
- streams.push(zlib__default["default"].createUnzip());
2870
+ streams.push(zlib__default["default"].createUnzip(zlibOptions));
2348
2871
 
2349
2872
  // remove the content-encoding in order to not confuse downstream operations
2350
2873
  delete res.headers['content-encoding'];
2351
2874
  break;
2352
2875
  case 'br':
2353
2876
  if (isBrotliSupported) {
2354
- streams.push(zlib__default["default"].createBrotliDecompress());
2877
+ streams.push(zlib__default["default"].createBrotliDecompress(brotliOptions));
2355
2878
  delete res.headers['content-encoding'];
2356
2879
  }
2357
2880
  }
2358
2881
  }
2359
2882
 
2360
- if (onDownloadProgress) {
2361
- const responseLength = +res.headers['content-length'];
2362
-
2363
- const transformStream = new AxiosTransformStream({
2364
- length: utils.toFiniteNumber(responseLength),
2365
- maxRate: utils.toFiniteNumber(maxDownloadRate)
2366
- });
2367
-
2368
- onDownloadProgress && transformStream.on('progress', progress => {
2369
- onDownloadProgress(Object.assign(progress, {
2370
- download: true
2371
- }));
2372
- });
2373
-
2374
- streams.push(transformStream);
2375
- }
2376
-
2377
2883
  responseStream = streams.length > 1 ? stream__default["default"].pipeline(streams, utils.noop) : streams[0];
2378
2884
 
2379
2885
  const offListeners = stream__default["default"].finished(responseStream, () => {
@@ -2384,7 +2890,7 @@ function httpAdapter(config) {
2384
2890
  const response = {
2385
2891
  status: res.statusCode,
2386
2892
  statusText: res.statusMessage,
2387
- headers: new AxiosHeaders(res.headers),
2893
+ headers: new AxiosHeaders$1(res.headers),
2388
2894
  config,
2389
2895
  request: lastRequest
2390
2896
  };
@@ -2537,7 +3043,7 @@ function httpAdapter(config) {
2537
3043
  req.end(data);
2538
3044
  }
2539
3045
  });
2540
- }
3046
+ };
2541
3047
 
2542
3048
  const cookies = platform.isStandardBrowserEnv ?
2543
3049
 
@@ -2669,7 +3175,8 @@ function progressEventReducer(listener, isDownloadStream) {
2669
3175
  progress: total ? (loaded / total) : undefined,
2670
3176
  bytes: progressBytes,
2671
3177
  rate: rate ? rate : undefined,
2672
- estimated: rate && total && inRange ? (total - loaded) / rate : undefined
3178
+ estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
3179
+ event: e
2673
3180
  };
2674
3181
 
2675
3182
  data[isDownloadStream ? 'download' : 'upload'] = true;
@@ -2678,10 +3185,12 @@ function progressEventReducer(listener, isDownloadStream) {
2678
3185
  };
2679
3186
  }
2680
3187
 
2681
- function xhrAdapter(config) {
3188
+ const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
3189
+
3190
+ const xhrAdapter = isXHRAdapterSupported && function (config) {
2682
3191
  return new Promise(function dispatchXhrRequest(resolve, reject) {
2683
3192
  let requestData = config.data;
2684
- const requestHeaders = AxiosHeaders.from(config.headers).normalize();
3193
+ const requestHeaders = AxiosHeaders$1.from(config.headers).normalize();
2685
3194
  const responseType = config.responseType;
2686
3195
  let onCanceled;
2687
3196
  function done() {
@@ -2694,7 +3203,7 @@ function xhrAdapter(config) {
2694
3203
  }
2695
3204
  }
2696
3205
 
2697
- if (utils.isFormData(requestData) && platform.isStandardBrowserEnv) {
3206
+ if (utils.isFormData(requestData) && (platform.isStandardBrowserEnv || platform.isStandardBrowserWebWorkerEnv)) {
2698
3207
  requestHeaders.setContentType(false); // Let the browser set it
2699
3208
  }
2700
3209
 
@@ -2719,10 +3228,10 @@ function xhrAdapter(config) {
2719
3228
  return;
2720
3229
  }
2721
3230
  // Prepare the response
2722
- const responseHeaders = AxiosHeaders.from(
3231
+ const responseHeaders = AxiosHeaders$1.from(
2723
3232
  'getAllResponseHeaders' in request && request.getAllResponseHeaders()
2724
3233
  );
2725
- const responseData = !responseType || responseType === 'text' || responseType === 'json' ?
3234
+ const responseData = !responseType || responseType === 'text' || responseType === 'json' ?
2726
3235
  request.responseText : request.response;
2727
3236
  const response = {
2728
3237
  data: responseData,
@@ -2879,238 +3388,63 @@ function xhrAdapter(config) {
2879
3388
  // Send the request
2880
3389
  request.send(requestData || null);
2881
3390
  });
2882
- }
3391
+ };
2883
3392
 
2884
- const adapters = {
3393
+ const knownAdapters = {
2885
3394
  http: httpAdapter,
2886
3395
  xhr: xhrAdapter
2887
3396
  };
2888
3397
 
2889
- const adapters$1 = {
2890
- getAdapter: (nameOrAdapter) => {
2891
- if(utils.isString(nameOrAdapter)){
2892
- const adapter = adapters[nameOrAdapter];
2893
-
2894
- if (!nameOrAdapter) {
2895
- throw Error(
2896
- utils.hasOwnProp(nameOrAdapter) ?
2897
- `Adapter '${nameOrAdapter}' is not available in the build` :
2898
- `Can not resolve adapter '${nameOrAdapter}'`
2899
- );
2900
- }
2901
-
2902
- return adapter
2903
- }
2904
-
2905
- if (!utils.isFunction(nameOrAdapter)) {
2906
- throw new TypeError('adapter is not a function');
2907
- }
2908
-
2909
- return nameOrAdapter;
2910
- },
2911
- adapters
2912
- };
2913
-
2914
- const DEFAULT_CONTENT_TYPE = {
2915
- 'Content-Type': 'application/x-www-form-urlencoded'
2916
- };
2917
-
2918
- /**
2919
- * If the browser has an XMLHttpRequest object, use the XHR adapter, otherwise use the HTTP
2920
- * adapter
2921
- *
2922
- * @returns {Function}
2923
- */
2924
- function getDefaultAdapter() {
2925
- let adapter;
2926
- if (typeof XMLHttpRequest !== 'undefined') {
2927
- // For browsers use XHR adapter
2928
- adapter = adapters$1.getAdapter('xhr');
2929
- } else if (typeof process !== 'undefined' && utils.kindOf(process) === 'process') {
2930
- // For node use HTTP adapter
2931
- adapter = adapters$1.getAdapter('http');
2932
- }
2933
- return adapter;
2934
- }
2935
-
2936
- /**
2937
- * It takes a string, tries to parse it, and if it fails, it returns the stringified version
2938
- * of the input
2939
- *
2940
- * @param {any} rawValue - The value to be stringified.
2941
- * @param {Function} parser - A function that parses a string into a JavaScript object.
2942
- * @param {Function} encoder - A function that takes a value and returns a string.
2943
- *
2944
- * @returns {string} A stringified version of the rawValue.
2945
- */
2946
- function stringifySafely(rawValue, parser, encoder) {
2947
- if (utils.isString(rawValue)) {
3398
+ utils.forEach(knownAdapters, (fn, value) => {
3399
+ if(fn) {
2948
3400
  try {
2949
- (parser || JSON.parse)(rawValue);
2950
- return utils.trim(rawValue);
3401
+ Object.defineProperty(fn, 'name', {value});
2951
3402
  } catch (e) {
2952
- if (e.name !== 'SyntaxError') {
2953
- throw e;
2954
- }
3403
+ // eslint-disable-next-line no-empty
2955
3404
  }
3405
+ Object.defineProperty(fn, 'adapterName', {value});
2956
3406
  }
3407
+ });
2957
3408
 
2958
- return (encoder || JSON.stringify)(rawValue);
2959
- }
2960
-
2961
- const defaults = {
2962
-
2963
- transitional: transitionalDefaults,
2964
-
2965
- adapter: getDefaultAdapter(),
2966
-
2967
- transformRequest: [function transformRequest(data, headers) {
2968
- const contentType = headers.getContentType() || '';
2969
- const hasJSONContentType = contentType.indexOf('application/json') > -1;
2970
- const isObjectPayload = utils.isObject(data);
2971
-
2972
- if (isObjectPayload && utils.isHTMLForm(data)) {
2973
- data = new FormData(data);
2974
- }
3409
+ const adapters = {
3410
+ getAdapter: (adapters) => {
3411
+ adapters = utils.isArray(adapters) ? adapters : [adapters];
2975
3412
 
2976
- const isFormData = utils.isFormData(data);
3413
+ const {length} = adapters;
3414
+ let nameOrAdapter;
3415
+ let adapter;
2977
3416
 
2978
- if (isFormData) {
2979
- if (!hasJSONContentType) {
2980
- return data;
3417
+ for (let i = 0; i < length; i++) {
3418
+ nameOrAdapter = adapters[i];
3419
+ if((adapter = utils.isString(nameOrAdapter) ? knownAdapters[nameOrAdapter.toLowerCase()] : nameOrAdapter)) {
3420
+ break;
2981
3421
  }
2982
- return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
2983
- }
2984
-
2985
- if (utils.isArrayBuffer(data) ||
2986
- utils.isBuffer(data) ||
2987
- utils.isStream(data) ||
2988
- utils.isFile(data) ||
2989
- utils.isBlob(data)
2990
- ) {
2991
- return data;
2992
- }
2993
- if (utils.isArrayBufferView(data)) {
2994
- return data.buffer;
2995
- }
2996
- if (utils.isURLSearchParams(data)) {
2997
- headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
2998
- return data.toString();
2999
3422
  }
3000
3423
 
3001
- let isFileList;
3002
-
3003
- if (isObjectPayload) {
3004
- if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
3005
- return toURLEncodedForm(data, this.formSerializer).toString();
3006
- }
3007
-
3008
- if ((isFileList = utils.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
3009
- const _FormData = this.env && this.env.FormData;
3010
-
3011
- return toFormData(
3012
- isFileList ? {'files[]': data} : data,
3013
- _FormData && new _FormData(),
3014
- this.formSerializer
3424
+ if (!adapter) {
3425
+ if (adapter === false) {
3426
+ throw new AxiosError(
3427
+ `Adapter ${nameOrAdapter} is not supported by the environment`,
3428
+ 'ERR_NOT_SUPPORT'
3015
3429
  );
3016
3430
  }
3017
- }
3018
3431
 
3019
- if (isObjectPayload || hasJSONContentType ) {
3020
- headers.setContentType('application/json', false);
3021
- return stringifySafely(data);
3432
+ throw new Error(
3433
+ utils.hasOwnProp(knownAdapters, nameOrAdapter) ?
3434
+ `Adapter '${nameOrAdapter}' is not available in the build` :
3435
+ `Unknown adapter '${nameOrAdapter}'`
3436
+ );
3022
3437
  }
3023
3438
 
3024
- return data;
3025
- }],
3026
-
3027
- transformResponse: [function transformResponse(data) {
3028
- const transitional = this.transitional || defaults.transitional;
3029
- const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
3030
- const JSONRequested = this.responseType === 'json';
3031
-
3032
- if (data && utils.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
3033
- const silentJSONParsing = transitional && transitional.silentJSONParsing;
3034
- const strictJSONParsing = !silentJSONParsing && JSONRequested;
3035
-
3036
- try {
3037
- return JSON.parse(data);
3038
- } catch (e) {
3039
- if (strictJSONParsing) {
3040
- if (e.name === 'SyntaxError') {
3041
- throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response);
3042
- }
3043
- throw e;
3044
- }
3045
- }
3439
+ if (!utils.isFunction(adapter)) {
3440
+ throw new TypeError('adapter is not a function');
3046
3441
  }
3047
3442
 
3048
- return data;
3049
- }],
3050
-
3051
- /**
3052
- * A timeout in milliseconds to abort a request. If set to 0 (default) a
3053
- * timeout is not created.
3054
- */
3055
- timeout: 0,
3056
-
3057
- xsrfCookieName: 'XSRF-TOKEN',
3058
- xsrfHeaderName: 'X-XSRF-TOKEN',
3059
-
3060
- maxContentLength: -1,
3061
- maxBodyLength: -1,
3062
-
3063
- env: {
3064
- FormData: platform.classes.FormData,
3065
- Blob: platform.classes.Blob
3066
- },
3067
-
3068
- validateStatus: function validateStatus(status) {
3069
- return status >= 200 && status < 300;
3443
+ return adapter;
3070
3444
  },
3071
-
3072
- headers: {
3073
- common: {
3074
- 'Accept': 'application/json, text/plain, */*'
3075
- }
3076
- }
3445
+ adapters: knownAdapters
3077
3446
  };
3078
3447
 
3079
- utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
3080
- defaults.headers[method] = {};
3081
- });
3082
-
3083
- utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
3084
- defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
3085
- });
3086
-
3087
- /**
3088
- * Transform the data for a request or a response
3089
- *
3090
- * @param {Array|Function} fns A single function or Array of functions
3091
- * @param {?Object} response The response object
3092
- *
3093
- * @returns {*} The resulting transformed data
3094
- */
3095
- function transformData(fns, response) {
3096
- const config = this || defaults;
3097
- const context = response || config;
3098
- const headers = AxiosHeaders.from(context.headers);
3099
- let data = context.data;
3100
-
3101
- utils.forEach(fns, function transform(fn) {
3102
- data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
3103
- });
3104
-
3105
- headers.normalize();
3106
-
3107
- return data;
3108
- }
3109
-
3110
- function isCancel(value) {
3111
- return !!(value && value.__CANCEL__);
3112
- }
3113
-
3114
3448
  /**
3115
3449
  * Throws a `CanceledError` if cancellation has been requested.
3116
3450
  *
@@ -3124,7 +3458,7 @@ function throwIfCancellationRequested(config) {
3124
3458
  }
3125
3459
 
3126
3460
  if (config.signal && config.signal.aborted) {
3127
- throw new CanceledError();
3461
+ throw new CanceledError(null, config);
3128
3462
  }
3129
3463
  }
3130
3464
 
@@ -3138,7 +3472,7 @@ function throwIfCancellationRequested(config) {
3138
3472
  function dispatchRequest(config) {
3139
3473
  throwIfCancellationRequested(config);
3140
3474
 
3141
- config.headers = AxiosHeaders.from(config.headers);
3475
+ config.headers = AxiosHeaders$1.from(config.headers);
3142
3476
 
3143
3477
  // Transform request data
3144
3478
  config.data = transformData.call(
@@ -3146,7 +3480,11 @@ function dispatchRequest(config) {
3146
3480
  config.transformRequest
3147
3481
  );
3148
3482
 
3149
- const adapter = config.adapter || defaults.adapter;
3483
+ if (['post', 'put', 'patch'].indexOf(config.method) !== -1) {
3484
+ config.headers.setContentType('application/x-www-form-urlencoded', false);
3485
+ }
3486
+
3487
+ const adapter = adapters.getAdapter(config.adapter || defaults$1.adapter);
3150
3488
 
3151
3489
  return adapter(config).then(function onAdapterResolution(response) {
3152
3490
  throwIfCancellationRequested(config);
@@ -3158,7 +3496,7 @@ function dispatchRequest(config) {
3158
3496
  response
3159
3497
  );
3160
3498
 
3161
- response.headers = AxiosHeaders.from(response.headers);
3499
+ response.headers = AxiosHeaders$1.from(response.headers);
3162
3500
 
3163
3501
  return response;
3164
3502
  }, function onAdapterRejection(reason) {
@@ -3172,7 +3510,7 @@ function dispatchRequest(config) {
3172
3510
  config.transformResponse,
3173
3511
  reason.response
3174
3512
  );
3175
- reason.response.headers = AxiosHeaders.from(reason.response.headers);
3513
+ reason.response.headers = AxiosHeaders$1.from(reason.response.headers);
3176
3514
  }
3177
3515
  }
3178
3516
 
@@ -3180,6 +3518,8 @@ function dispatchRequest(config) {
3180
3518
  });
3181
3519
  }
3182
3520
 
3521
+ const headersToObject = (thing) => thing instanceof AxiosHeaders$1 ? thing.toJSON() : thing;
3522
+
3183
3523
  /**
3184
3524
  * Config-specific merge-function which creates a new config-object
3185
3525
  * by merging two configuration objects together.
@@ -3194,9 +3534,9 @@ function mergeConfig(config1, config2) {
3194
3534
  config2 = config2 || {};
3195
3535
  const config = {};
3196
3536
 
3197
- function getMergedValue(target, source) {
3537
+ function getMergedValue(target, source, caseless) {
3198
3538
  if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
3199
- return utils.merge(target, source);
3539
+ return utils.merge.call({caseless}, target, source);
3200
3540
  } else if (utils.isPlainObject(source)) {
3201
3541
  return utils.merge({}, source);
3202
3542
  } else if (utils.isArray(source)) {
@@ -3206,72 +3546,73 @@ function mergeConfig(config1, config2) {
3206
3546
  }
3207
3547
 
3208
3548
  // eslint-disable-next-line consistent-return
3209
- function mergeDeepProperties(prop) {
3210
- if (!utils.isUndefined(config2[prop])) {
3211
- return getMergedValue(config1[prop], config2[prop]);
3212
- } else if (!utils.isUndefined(config1[prop])) {
3213
- return getMergedValue(undefined, config1[prop]);
3549
+ function mergeDeepProperties(a, b, caseless) {
3550
+ if (!utils.isUndefined(b)) {
3551
+ return getMergedValue(a, b, caseless);
3552
+ } else if (!utils.isUndefined(a)) {
3553
+ return getMergedValue(undefined, a, caseless);
3214
3554
  }
3215
3555
  }
3216
3556
 
3217
3557
  // eslint-disable-next-line consistent-return
3218
- function valueFromConfig2(prop) {
3219
- if (!utils.isUndefined(config2[prop])) {
3220
- return getMergedValue(undefined, config2[prop]);
3558
+ function valueFromConfig2(a, b) {
3559
+ if (!utils.isUndefined(b)) {
3560
+ return getMergedValue(undefined, b);
3221
3561
  }
3222
3562
  }
3223
3563
 
3224
3564
  // eslint-disable-next-line consistent-return
3225
- function defaultToConfig2(prop) {
3226
- if (!utils.isUndefined(config2[prop])) {
3227
- return getMergedValue(undefined, config2[prop]);
3228
- } else if (!utils.isUndefined(config1[prop])) {
3229
- return getMergedValue(undefined, config1[prop]);
3565
+ function defaultToConfig2(a, b) {
3566
+ if (!utils.isUndefined(b)) {
3567
+ return getMergedValue(undefined, b);
3568
+ } else if (!utils.isUndefined(a)) {
3569
+ return getMergedValue(undefined, a);
3230
3570
  }
3231
3571
  }
3232
3572
 
3233
3573
  // eslint-disable-next-line consistent-return
3234
- function mergeDirectKeys(prop) {
3574
+ function mergeDirectKeys(a, b, prop) {
3235
3575
  if (prop in config2) {
3236
- return getMergedValue(config1[prop], config2[prop]);
3576
+ return getMergedValue(a, b);
3237
3577
  } else if (prop in config1) {
3238
- return getMergedValue(undefined, config1[prop]);
3578
+ return getMergedValue(undefined, a);
3239
3579
  }
3240
3580
  }
3241
3581
 
3242
3582
  const mergeMap = {
3243
- 'url': valueFromConfig2,
3244
- 'method': valueFromConfig2,
3245
- 'data': valueFromConfig2,
3246
- 'baseURL': defaultToConfig2,
3247
- 'transformRequest': defaultToConfig2,
3248
- 'transformResponse': defaultToConfig2,
3249
- 'paramsSerializer': defaultToConfig2,
3250
- 'timeout': defaultToConfig2,
3251
- 'timeoutMessage': defaultToConfig2,
3252
- 'withCredentials': defaultToConfig2,
3253
- 'adapter': defaultToConfig2,
3254
- 'responseType': defaultToConfig2,
3255
- 'xsrfCookieName': defaultToConfig2,
3256
- 'xsrfHeaderName': defaultToConfig2,
3257
- 'onUploadProgress': defaultToConfig2,
3258
- 'onDownloadProgress': defaultToConfig2,
3259
- 'decompress': defaultToConfig2,
3260
- 'maxContentLength': defaultToConfig2,
3261
- 'maxBodyLength': defaultToConfig2,
3262
- 'beforeRedirect': defaultToConfig2,
3263
- 'transport': defaultToConfig2,
3264
- 'httpAgent': defaultToConfig2,
3265
- 'httpsAgent': defaultToConfig2,
3266
- 'cancelToken': defaultToConfig2,
3267
- 'socketPath': defaultToConfig2,
3268
- 'responseEncoding': defaultToConfig2,
3269
- 'validateStatus': mergeDirectKeys
3583
+ url: valueFromConfig2,
3584
+ method: valueFromConfig2,
3585
+ data: valueFromConfig2,
3586
+ baseURL: defaultToConfig2,
3587
+ transformRequest: defaultToConfig2,
3588
+ transformResponse: defaultToConfig2,
3589
+ paramsSerializer: defaultToConfig2,
3590
+ timeout: defaultToConfig2,
3591
+ timeoutMessage: defaultToConfig2,
3592
+ withCredentials: defaultToConfig2,
3593
+ adapter: defaultToConfig2,
3594
+ responseType: defaultToConfig2,
3595
+ xsrfCookieName: defaultToConfig2,
3596
+ xsrfHeaderName: defaultToConfig2,
3597
+ onUploadProgress: defaultToConfig2,
3598
+ onDownloadProgress: defaultToConfig2,
3599
+ decompress: defaultToConfig2,
3600
+ maxContentLength: defaultToConfig2,
3601
+ maxBodyLength: defaultToConfig2,
3602
+ beforeRedirect: defaultToConfig2,
3603
+ transport: defaultToConfig2,
3604
+ httpAgent: defaultToConfig2,
3605
+ httpsAgent: defaultToConfig2,
3606
+ cancelToken: defaultToConfig2,
3607
+ socketPath: defaultToConfig2,
3608
+ responseEncoding: defaultToConfig2,
3609
+ validateStatus: mergeDirectKeys,
3610
+ headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
3270
3611
  };
3271
3612
 
3272
3613
  utils.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) {
3273
3614
  const merge = mergeMap[prop] || mergeDeepProperties;
3274
- const configValue = merge(prop);
3615
+ const configValue = merge(config1[prop], config2[prop], prop);
3275
3616
  (utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
3276
3617
  });
3277
3618
 
@@ -3378,8 +3719,8 @@ class Axios {
3378
3719
  constructor(instanceConfig) {
3379
3720
  this.defaults = instanceConfig;
3380
3721
  this.interceptors = {
3381
- request: new InterceptorManager(),
3382
- response: new InterceptorManager()
3722
+ request: new InterceptorManager$1(),
3723
+ response: new InterceptorManager$1()
3383
3724
  };
3384
3725
  }
3385
3726
 
@@ -3403,7 +3744,7 @@ class Axios {
3403
3744
 
3404
3745
  config = mergeConfig(this.defaults, config);
3405
3746
 
3406
- const {transitional, paramsSerializer} = config;
3747
+ const {transitional, paramsSerializer, headers} = config;
3407
3748
 
3408
3749
  if (transitional !== undefined) {
3409
3750
  validator.assertOptions(transitional, {
@@ -3423,20 +3764,22 @@ class Axios {
3423
3764
  // Set config.method
3424
3765
  config.method = (config.method || this.defaults.method || 'get').toLowerCase();
3425
3766
 
3767
+ let contextHeaders;
3768
+
3426
3769
  // Flatten headers
3427
- const defaultHeaders = config.headers && utils.merge(
3428
- config.headers.common,
3429
- config.headers[config.method]
3770
+ contextHeaders = headers && utils.merge(
3771
+ headers.common,
3772
+ headers[config.method]
3430
3773
  );
3431
3774
 
3432
- defaultHeaders && utils.forEach(
3775
+ contextHeaders && utils.forEach(
3433
3776
  ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
3434
- function cleanHeaderConfig(method) {
3435
- delete config.headers[method];
3777
+ (method) => {
3778
+ delete headers[method];
3436
3779
  }
3437
3780
  );
3438
3781
 
3439
- config.headers = new AxiosHeaders(config.headers, defaultHeaders);
3782
+ config.headers = AxiosHeaders$1.concat(contextHeaders, headers);
3440
3783
 
3441
3784
  // filter out skipped interceptors
3442
3785
  const requestInterceptorChain = [];
@@ -3548,6 +3891,8 @@ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
3548
3891
  Axios.prototype[method + 'Form'] = generateHTTPMethod(true);
3549
3892
  });
3550
3893
 
3894
+ const Axios$1 = Axios;
3895
+
3551
3896
  /**
3552
3897
  * A `CancelToken` is an object that can be used to request cancellation of an operation.
3553
3898
  *
@@ -3664,6 +4009,8 @@ class CancelToken {
3664
4009
  }
3665
4010
  }
3666
4011
 
4012
+ const CancelToken$1 = CancelToken;
4013
+
3667
4014
  /**
3668
4015
  * Syntactic sugar for invoking a function and expanding an array for arguments.
3669
4016
  *
@@ -3702,6 +4049,78 @@ function isAxiosError(payload) {
3702
4049
  return utils.isObject(payload) && (payload.isAxiosError === true);
3703
4050
  }
3704
4051
 
4052
+ const HttpStatusCode = {
4053
+ Continue: 100,
4054
+ SwitchingProtocols: 101,
4055
+ Processing: 102,
4056
+ EarlyHints: 103,
4057
+ Ok: 200,
4058
+ Created: 201,
4059
+ Accepted: 202,
4060
+ NonAuthoritativeInformation: 203,
4061
+ NoContent: 204,
4062
+ ResetContent: 205,
4063
+ PartialContent: 206,
4064
+ MultiStatus: 207,
4065
+ AlreadyReported: 208,
4066
+ ImUsed: 226,
4067
+ MultipleChoices: 300,
4068
+ MovedPermanently: 301,
4069
+ Found: 302,
4070
+ SeeOther: 303,
4071
+ NotModified: 304,
4072
+ UseProxy: 305,
4073
+ Unused: 306,
4074
+ TemporaryRedirect: 307,
4075
+ PermanentRedirect: 308,
4076
+ BadRequest: 400,
4077
+ Unauthorized: 401,
4078
+ PaymentRequired: 402,
4079
+ Forbidden: 403,
4080
+ NotFound: 404,
4081
+ MethodNotAllowed: 405,
4082
+ NotAcceptable: 406,
4083
+ ProxyAuthenticationRequired: 407,
4084
+ RequestTimeout: 408,
4085
+ Conflict: 409,
4086
+ Gone: 410,
4087
+ LengthRequired: 411,
4088
+ PreconditionFailed: 412,
4089
+ PayloadTooLarge: 413,
4090
+ UriTooLong: 414,
4091
+ UnsupportedMediaType: 415,
4092
+ RangeNotSatisfiable: 416,
4093
+ ExpectationFailed: 417,
4094
+ ImATeapot: 418,
4095
+ MisdirectedRequest: 421,
4096
+ UnprocessableEntity: 422,
4097
+ Locked: 423,
4098
+ FailedDependency: 424,
4099
+ TooEarly: 425,
4100
+ UpgradeRequired: 426,
4101
+ PreconditionRequired: 428,
4102
+ TooManyRequests: 429,
4103
+ RequestHeaderFieldsTooLarge: 431,
4104
+ UnavailableForLegalReasons: 451,
4105
+ InternalServerError: 500,
4106
+ NotImplemented: 501,
4107
+ BadGateway: 502,
4108
+ ServiceUnavailable: 503,
4109
+ GatewayTimeout: 504,
4110
+ HttpVersionNotSupported: 505,
4111
+ VariantAlsoNegotiates: 506,
4112
+ InsufficientStorage: 507,
4113
+ LoopDetected: 508,
4114
+ NotExtended: 510,
4115
+ NetworkAuthenticationRequired: 511,
4116
+ };
4117
+
4118
+ Object.entries(HttpStatusCode).forEach(([key, value]) => {
4119
+ HttpStatusCode[value] = key;
4120
+ });
4121
+
4122
+ const HttpStatusCode$1 = HttpStatusCode;
4123
+
3705
4124
  /**
3706
4125
  * Create an instance of Axios
3707
4126
  *
@@ -3710,11 +4129,11 @@ function isAxiosError(payload) {
3710
4129
  * @returns {Axios} A new instance of Axios
3711
4130
  */
3712
4131
  function createInstance(defaultConfig) {
3713
- const context = new Axios(defaultConfig);
3714
- const instance = bind(Axios.prototype.request, context);
4132
+ const context = new Axios$1(defaultConfig);
4133
+ const instance = bind(Axios$1.prototype.request, context);
3715
4134
 
3716
4135
  // Copy axios.prototype to instance
3717
- utils.extend(instance, Axios.prototype, context, {allOwnKeys: true});
4136
+ utils.extend(instance, Axios$1.prototype, context, {allOwnKeys: true});
3718
4137
 
3719
4138
  // Copy context to instance
3720
4139
  utils.extend(instance, context, null, {allOwnKeys: true});
@@ -3728,14 +4147,14 @@ function createInstance(defaultConfig) {
3728
4147
  }
3729
4148
 
3730
4149
  // Create the default instance to be exported
3731
- const axios = createInstance(defaults);
4150
+ const axios = createInstance(defaults$1);
3732
4151
 
3733
4152
  // Expose Axios class to allow class inheritance
3734
- axios.Axios = Axios;
4153
+ axios.Axios = Axios$1;
3735
4154
 
3736
4155
  // Expose Cancel & CancelToken
3737
4156
  axios.CanceledError = CanceledError;
3738
- axios.CancelToken = CancelToken;
4157
+ axios.CancelToken = CancelToken$1;
3739
4158
  axios.isCancel = isCancel;
3740
4159
  axios.VERSION = VERSION;
3741
4160
  axios.toFormData = toFormData;
@@ -3756,9 +4175,16 @@ axios.spread = spread;
3756
4175
  // Expose isAxiosError
3757
4176
  axios.isAxiosError = isAxiosError;
3758
4177
 
3759
- axios.formToJSON = thing => {
3760
- return formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing);
3761
- };
4178
+ // Expose mergeConfig
4179
+ axios.mergeConfig = mergeConfig;
4180
+
4181
+ axios.AxiosHeaders = AxiosHeaders$1;
4182
+
4183
+ axios.formToJSON = thing => formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing);
4184
+
4185
+ axios.HttpStatusCode = HttpStatusCode$1;
4186
+
4187
+ axios.default = axios;
3762
4188
 
3763
4189
  module.exports = axios;
3764
4190
  //# sourceMappingURL=axios.cjs.map