axios 1.7.0-beta.1 → 1.7.0-beta.2

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.7.0-beta.1 Copyright (c) 2024 Matt Zabriskie and contributors
1
+ // Axios v1.7.0-beta.2 Copyright (c) 2024 Matt Zabriskie and contributors
2
2
  'use strict';
3
3
 
4
4
  function bind(fn, thisArg) {
@@ -2722,6 +2722,10 @@ isFetchSupported && (((res) => {
2722
2722
  })(new Response));
2723
2723
 
2724
2724
  const getBodyLength = async (body) => {
2725
+ if (body == null) {
2726
+ return 0;
2727
+ }
2728
+
2725
2729
  if(utils$1.isBlob(body)) {
2726
2730
  return body.size;
2727
2731
  }
@@ -2780,12 +2784,15 @@ var fetchAdapter = isFetchSupported && (async (config) => {
2780
2784
  finished = true;
2781
2785
  };
2782
2786
 
2783
- try {
2784
- if (onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head') {
2785
- let requestContentLength = await resolveBodyLength(headers, data);
2787
+ let requestContentLength;
2786
2788
 
2789
+ try {
2790
+ if (
2791
+ onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head' &&
2792
+ (requestContentLength = await resolveBodyLength(headers, data)) !== 0
2793
+ ) {
2787
2794
  let _request = new Request(url, {
2788
- method,
2795
+ method: 'POST',
2789
2796
  body: data,
2790
2797
  duplex: "half"
2791
2798
  });
@@ -2796,10 +2803,12 @@ var fetchAdapter = isFetchSupported && (async (config) => {
2796
2803
  headers.setContentType(contentTypeHeader);
2797
2804
  }
2798
2805
 
2799
- data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, fetchProgressDecorator(
2800
- requestContentLength,
2801
- progressEventReducer(onUploadProgress)
2802
- ));
2806
+ if (_request.body) {
2807
+ data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, fetchProgressDecorator(
2808
+ requestContentLength,
2809
+ progressEventReducer(onUploadProgress)
2810
+ ));
2811
+ }
2803
2812
  }
2804
2813
 
2805
2814
  if (!utils$1.isString(withCredentials)) {
@@ -2809,7 +2818,7 @@ var fetchAdapter = isFetchSupported && (async (config) => {
2809
2818
  request = new Request(url, {
2810
2819
  ...fetchOptions,
2811
2820
  signal: composedSignal,
2812
- method,
2821
+ method: method.toUpperCase(),
2813
2822
  headers: headers.normalize().toJSON(),
2814
2823
  body: data,
2815
2824
  duplex: "half",
@@ -2823,7 +2832,7 @@ var fetchAdapter = isFetchSupported && (async (config) => {
2823
2832
  if (supportsResponseStream && (onDownloadProgress || isStreamResponse)) {
2824
2833
  const options = {};
2825
2834
 
2826
- Object.getOwnPropertyNames(response).forEach(prop => {
2835
+ ['status', 'statusText', 'headers'].forEach(prop => {
2827
2836
  options[prop] = response[prop];
2828
2837
  });
2829
2838
 
@@ -3019,7 +3028,7 @@ function dispatchRequest(config) {
3019
3028
  });
3020
3029
  }
3021
3030
 
3022
- const VERSION = "1.7.0-beta.1";
3031
+ const VERSION = "1.7.0-beta.2";
3023
3032
 
3024
3033
  const validators$1 = {};
3025
3034