axios 1.2.0 → 1.2.1

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.

@@ -1,4 +1,4 @@
1
- // Axios v1.2.0 Copyright (c) 2022 Matt Zabriskie and contributors
1
+ // Axios v1.2.1 Copyright (c) 2022 Matt Zabriskie and contributors
2
2
  'use strict';
3
3
 
4
4
  const FormData$1 = require('form-data');
@@ -1907,7 +1907,7 @@ function buildFullPath(baseURL, requestedURL) {
1907
1907
  return requestedURL;
1908
1908
  }
1909
1909
 
1910
- const VERSION = "1.2.0";
1910
+ const VERSION = "1.2.1";
1911
1911
 
1912
1912
  function parseProtocol(url) {
1913
1913
  const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
@@ -2040,7 +2040,7 @@ function speedometer(samplesCount, min) {
2040
2040
 
2041
2041
  const passed = startedAt && now - startedAt;
2042
2042
 
2043
- return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
2043
+ return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
2044
2044
  };
2045
2045
  }
2046
2046
 
@@ -2229,6 +2229,11 @@ class AxiosTransformStream extends stream__default["default"].Transform{
2229
2229
 
2230
2230
  const AxiosTransformStream$1 = AxiosTransformStream;
2231
2231
 
2232
+ const zlibOptions = {
2233
+ flush: zlib__default["default"].constants.Z_SYNC_FLUSH,
2234
+ finishFlush: zlib__default["default"].constants.Z_SYNC_FLUSH
2235
+ };
2236
+
2232
2237
  const isBrotliSupported = utils.isFunction(zlib__default["default"].createBrotliDecompress);
2233
2238
 
2234
2239
  const {http: httpFollow, https: httpsFollow} = followRedirects__default["default"];
@@ -2469,7 +2474,7 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
2469
2474
  }
2470
2475
  }
2471
2476
 
2472
- const contentLength = +headers.getContentLength();
2477
+ const contentLength = utils.toFiniteNumber(headers.getContentLength());
2473
2478
 
2474
2479
  if (utils.isArray(maxRate)) {
2475
2480
  maxUploadRate = maxRate[0];
@@ -2484,7 +2489,7 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
2484
2489
  }
2485
2490
 
2486
2491
  data = stream__default["default"].pipeline([data, new AxiosTransformStream$1({
2487
- length: utils.toFiniteNumber(contentLength),
2492
+ length: contentLength,
2488
2493
  maxRate: utils.toFiniteNumber(maxUploadRate)
2489
2494
  })], utils.noop);
2490
2495
 
@@ -2527,7 +2532,10 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
2527
2532
  return reject(customErr);
2528
2533
  }
2529
2534
 
2530
- headers.set('Accept-Encoding', 'gzip, deflate, br', false);
2535
+ headers.set(
2536
+ 'Accept-Encoding',
2537
+ 'gzip, compress, deflate' + (isBrotliSupported ? ', br' : ''), false
2538
+ );
2531
2539
 
2532
2540
  const options = {
2533
2541
  path,
@@ -2599,17 +2607,17 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
2599
2607
  streams.push(transformStream);
2600
2608
  }
2601
2609
 
2602
- // uncompress the response body transparently if required
2610
+ // decompress the response body transparently if required
2603
2611
  let responseStream = res;
2604
2612
 
2605
2613
  // return the last request in case of redirects
2606
2614
  const lastRequest = res.req || req;
2607
2615
 
2608
2616
  // if decompress disabled we should not decompress
2609
- if (config.decompress !== false) {
2617
+ if (config.decompress !== false && res.headers['content-encoding']) {
2610
2618
  // if no content, but headers still say that it is encoded,
2611
2619
  // remove the header not confuse downstream operations
2612
- if ((!responseLength || res.statusCode === 204) && res.headers['content-encoding']) {
2620
+ if (method === 'HEAD' || res.statusCode === 204) {
2613
2621
  delete res.headers['content-encoding'];
2614
2622
  }
2615
2623
 
@@ -2619,14 +2627,14 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
2619
2627
  case 'compress':
2620
2628
  case 'deflate':
2621
2629
  // add the unzipper to the body stream processing pipeline
2622
- streams.push(zlib__default["default"].createUnzip());
2630
+ streams.push(zlib__default["default"].createUnzip(zlibOptions));
2623
2631
 
2624
2632
  // remove the content-encoding in order to not confuse downstream operations
2625
2633
  delete res.headers['content-encoding'];
2626
2634
  break;
2627
2635
  case 'br':
2628
2636
  if (isBrotliSupported) {
2629
- streams.push(zlib__default["default"].createBrotliDecompress());
2637
+ streams.push(zlib__default["default"].createBrotliDecompress(zlibOptions));
2630
2638
  delete res.headers['content-encoding'];
2631
2639
  }
2632
2640
  }
@@ -2955,7 +2963,7 @@ const xhrAdapter = isXHRAdapterSupported && function (config) {
2955
2963
  }
2956
2964
  }
2957
2965
 
2958
- if (utils.isFormData(requestData) && platform.isStandardBrowserEnv) {
2966
+ if (utils.isFormData(requestData) && (platform.isStandardBrowserEnv || platform.isStandardBrowserWebWorkerEnv)) {
2959
2967
  requestHeaders.setContentType(false); // Let the browser set it
2960
2968
  }
2961
2969
 
@@ -2983,7 +2991,7 @@ const xhrAdapter = isXHRAdapterSupported && function (config) {
2983
2991
  const responseHeaders = AxiosHeaders$1.from(
2984
2992
  'getAllResponseHeaders' in request && request.getAllResponseHeaders()
2985
2993
  );
2986
- const responseData = !responseType || responseType === 'text' || responseType === 'json' ?
2994
+ const responseData = !responseType || responseType === 'text' || responseType === 'json' ?
2987
2995
  request.responseText : request.response;
2988
2996
  const response = {
2989
2997
  data: responseData,
@@ -3210,7 +3218,7 @@ function throwIfCancellationRequested(config) {
3210
3218
  }
3211
3219
 
3212
3220
  if (config.signal && config.signal.aborted) {
3213
- throw new CanceledError();
3221
+ throw new CanceledError(null, config);
3214
3222
  }
3215
3223
  }
3216
3224
 
@@ -3855,6 +3863,9 @@ axios.spread = spread;
3855
3863
  // Expose isAxiosError
3856
3864
  axios.isAxiosError = isAxiosError;
3857
3865
 
3866
+ // Expose mergeConfig
3867
+ axios.mergeConfig = mergeConfig;
3868
+
3858
3869
  axios.AxiosHeaders = AxiosHeaders$1;
3859
3870
 
3860
3871
  axios.formToJSON = thing => formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing);