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
  const FormData$1 = require('form-data');
@@ -2035,7 +2035,7 @@ function buildFullPath(baseURL, requestedURL) {
2035
2035
  return requestedURL;
2036
2036
  }
2037
2037
 
2038
- const VERSION = "1.7.0-beta.1";
2038
+ const VERSION = "1.7.0-beta.2";
2039
2039
 
2040
2040
  function parseProtocol(url) {
2041
2041
  const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
@@ -3791,6 +3791,10 @@ isFetchSupported && (((res) => {
3791
3791
  })(new Response));
3792
3792
 
3793
3793
  const getBodyLength = async (body) => {
3794
+ if (body == null) {
3795
+ return 0;
3796
+ }
3797
+
3794
3798
  if(utils$1.isBlob(body)) {
3795
3799
  return body.size;
3796
3800
  }
@@ -3849,12 +3853,15 @@ const fetchAdapter = isFetchSupported && (async (config) => {
3849
3853
  finished = true;
3850
3854
  };
3851
3855
 
3852
- try {
3853
- if (onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head') {
3854
- let requestContentLength = await resolveBodyLength(headers, data);
3856
+ let requestContentLength;
3855
3857
 
3858
+ try {
3859
+ if (
3860
+ onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head' &&
3861
+ (requestContentLength = await resolveBodyLength(headers, data)) !== 0
3862
+ ) {
3856
3863
  let _request = new Request(url, {
3857
- method,
3864
+ method: 'POST',
3858
3865
  body: data,
3859
3866
  duplex: "half"
3860
3867
  });
@@ -3865,10 +3872,12 @@ const fetchAdapter = isFetchSupported && (async (config) => {
3865
3872
  headers.setContentType(contentTypeHeader);
3866
3873
  }
3867
3874
 
3868
- data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, fetchProgressDecorator(
3869
- requestContentLength,
3870
- progressEventReducer(onUploadProgress)
3871
- ));
3875
+ if (_request.body) {
3876
+ data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, fetchProgressDecorator(
3877
+ requestContentLength,
3878
+ progressEventReducer(onUploadProgress)
3879
+ ));
3880
+ }
3872
3881
  }
3873
3882
 
3874
3883
  if (!utils$1.isString(withCredentials)) {
@@ -3878,7 +3887,7 @@ const fetchAdapter = isFetchSupported && (async (config) => {
3878
3887
  request = new Request(url, {
3879
3888
  ...fetchOptions,
3880
3889
  signal: composedSignal,
3881
- method,
3890
+ method: method.toUpperCase(),
3882
3891
  headers: headers.normalize().toJSON(),
3883
3892
  body: data,
3884
3893
  duplex: "half",
@@ -3892,7 +3901,7 @@ const fetchAdapter = isFetchSupported && (async (config) => {
3892
3901
  if (supportsResponseStream && (onDownloadProgress || isStreamResponse)) {
3893
3902
  const options = {};
3894
3903
 
3895
- Object.getOwnPropertyNames(response).forEach(prop => {
3904
+ ['status', 'statusText', 'headers'].forEach(prop => {
3896
3905
  options[prop] = response[prop];
3897
3906
  });
3898
3907