axios 1.7.0-beta.0 → 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.
- package/CHANGELOG.md +27 -0
- package/dist/axios.js +90 -57
- package/dist/axios.js.map +1 -1
- package/dist/axios.min.js +1 -1
- package/dist/axios.min.js.map +1 -1
- package/dist/browser/axios.cjs +60 -33
- package/dist/browser/axios.cjs.map +1 -1
- package/dist/esm/axios.js +60 -33
- package/dist/esm/axios.js.map +1 -1
- package/dist/esm/axios.min.js +1 -1
- package/dist/esm/axios.min.js.map +1 -1
- package/dist/node/axios.cjs +60 -33
- package/dist/node/axios.cjs.map +1 -1
- package/lib/adapters/fetch.js +49 -25
- package/lib/core/Axios.js +9 -6
- package/lib/env/data.js +1 -1
- package/package.json +1 -1
package/dist/node/axios.cjs
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
// Axios v1.7.0-beta.
|
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.
|
2038
|
+
const VERSION = "1.7.0-beta.2";
|
2039
2039
|
|
2040
2040
|
function parseProtocol(url) {
|
2041
2041
|
const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
|
@@ -3750,8 +3750,9 @@ const fetchProgressDecorator = (total, fn) => {
|
|
3750
3750
|
};
|
3751
3751
|
|
3752
3752
|
const isFetchSupported = typeof fetch !== 'undefined';
|
3753
|
+
const isReadableStreamSupported = isFetchSupported && typeof ReadableStream !== 'undefined';
|
3753
3754
|
|
3754
|
-
const
|
3755
|
+
const supportsRequestStream = isReadableStreamSupported && (() => {
|
3755
3756
|
let duplexAccessed = false;
|
3756
3757
|
|
3757
3758
|
const hasContentType = new Request(platform.origin, {
|
@@ -3768,17 +3769,32 @@ const supportsRequestStreams = isFetchSupported && (() => {
|
|
3768
3769
|
|
3769
3770
|
const DEFAULT_CHUNK_SIZE = 64 * 1024;
|
3770
3771
|
|
3772
|
+
const supportsResponseStream = isReadableStreamSupported && !!(()=> {
|
3773
|
+
try {
|
3774
|
+
return utils$1.isReadableStream(new Response('').body);
|
3775
|
+
} catch(err) {
|
3776
|
+
// return undefined
|
3777
|
+
}
|
3778
|
+
})();
|
3779
|
+
|
3771
3780
|
const resolvers = {
|
3772
|
-
stream: (res) => res.body
|
3781
|
+
stream: supportsResponseStream && ((res) => res.body)
|
3773
3782
|
};
|
3774
3783
|
|
3775
|
-
isFetchSupported &&
|
3776
|
-
|
3777
|
-
|
3778
|
-
|
3779
|
-
|
3784
|
+
isFetchSupported && (((res) => {
|
3785
|
+
['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(type => {
|
3786
|
+
!resolvers[type] && (resolvers[type] = utils$1.isFunction(res[type]) ? (res) => res[type]() :
|
3787
|
+
(_, config) => {
|
3788
|
+
throw new AxiosError(`Response type '${type}' is not supported`, AxiosError.ERR_NOT_SUPPORT, config);
|
3789
|
+
});
|
3790
|
+
});
|
3791
|
+
})(new Response));
|
3780
3792
|
|
3781
3793
|
const getBodyLength = async (body) => {
|
3794
|
+
if (body == null) {
|
3795
|
+
return 0;
|
3796
|
+
}
|
3797
|
+
|
3782
3798
|
if(utils$1.isBlob(body)) {
|
3783
3799
|
return body.size;
|
3784
3800
|
}
|
@@ -3806,7 +3822,7 @@ const resolveBodyLength = async (headers, body) => {
|
|
3806
3822
|
return length == null ? getBodyLength(body) : length;
|
3807
3823
|
};
|
3808
3824
|
|
3809
|
-
const fetchAdapter = async (config) => {
|
3825
|
+
const fetchAdapter = isFetchSupported && (async (config) => {
|
3810
3826
|
let {
|
3811
3827
|
url,
|
3812
3828
|
method,
|
@@ -3837,12 +3853,15 @@ const fetchAdapter = async (config) => {
|
|
3837
3853
|
finished = true;
|
3838
3854
|
};
|
3839
3855
|
|
3840
|
-
|
3841
|
-
if (onUploadProgress && supportsRequestStreams && method !== 'get' && method !== 'head') {
|
3842
|
-
let requestContentLength = await resolveBodyLength(headers, data);
|
3856
|
+
let requestContentLength;
|
3843
3857
|
|
3858
|
+
try {
|
3859
|
+
if (
|
3860
|
+
onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head' &&
|
3861
|
+
(requestContentLength = await resolveBodyLength(headers, data)) !== 0
|
3862
|
+
) {
|
3844
3863
|
let _request = new Request(url, {
|
3845
|
-
method,
|
3864
|
+
method: 'POST',
|
3846
3865
|
body: data,
|
3847
3866
|
duplex: "half"
|
3848
3867
|
});
|
@@ -3853,10 +3872,12 @@ const fetchAdapter = async (config) => {
|
|
3853
3872
|
headers.setContentType(contentTypeHeader);
|
3854
3873
|
}
|
3855
3874
|
|
3856
|
-
|
3857
|
-
|
3858
|
-
|
3859
|
-
|
3875
|
+
if (_request.body) {
|
3876
|
+
data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, fetchProgressDecorator(
|
3877
|
+
requestContentLength,
|
3878
|
+
progressEventReducer(onUploadProgress)
|
3879
|
+
));
|
3880
|
+
}
|
3860
3881
|
}
|
3861
3882
|
|
3862
3883
|
if (!utils$1.isString(withCredentials)) {
|
@@ -3866,7 +3887,7 @@ const fetchAdapter = async (config) => {
|
|
3866
3887
|
request = new Request(url, {
|
3867
3888
|
...fetchOptions,
|
3868
3889
|
signal: composedSignal,
|
3869
|
-
method,
|
3890
|
+
method: method.toUpperCase(),
|
3870
3891
|
headers: headers.normalize().toJSON(),
|
3871
3892
|
body: data,
|
3872
3893
|
duplex: "half",
|
@@ -3877,10 +3898,10 @@ const fetchAdapter = async (config) => {
|
|
3877
3898
|
|
3878
3899
|
const isStreamResponse = responseType === 'stream' || responseType === 'response';
|
3879
3900
|
|
3880
|
-
if (onDownloadProgress || isStreamResponse) {
|
3901
|
+
if (supportsResponseStream && (onDownloadProgress || isStreamResponse)) {
|
3881
3902
|
const options = {};
|
3882
3903
|
|
3883
|
-
|
3904
|
+
['status', 'statusText', 'headers'].forEach(prop => {
|
3884
3905
|
options[prop] = response[prop];
|
3885
3906
|
});
|
3886
3907
|
|
@@ -3916,15 +3937,18 @@ const fetchAdapter = async (config) => {
|
|
3916
3937
|
} catch (err) {
|
3917
3938
|
onFinish();
|
3918
3939
|
|
3919
|
-
|
3920
|
-
|
3921
|
-
|
3922
|
-
|
3940
|
+
if (err && err.name === 'TypeError' && /fetch/i.test(err.message)) {
|
3941
|
+
throw Object.assign(
|
3942
|
+
new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request),
|
3943
|
+
{
|
3944
|
+
cause: err.cause || err
|
3945
|
+
}
|
3946
|
+
)
|
3923
3947
|
}
|
3924
3948
|
|
3925
|
-
throw AxiosError.from(err, code, config, request);
|
3949
|
+
throw AxiosError.from(err, err && err.code, config, request);
|
3926
3950
|
}
|
3927
|
-
};
|
3951
|
+
});
|
3928
3952
|
|
3929
3953
|
const knownAdapters = {
|
3930
3954
|
http: httpAdapter,
|
@@ -4197,12 +4221,15 @@ class Axios {
|
|
4197
4221
|
|
4198
4222
|
// slice off the Error: ... line
|
4199
4223
|
const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, '') : '';
|
4200
|
-
|
4201
|
-
|
4202
|
-
|
4203
|
-
|
4204
|
-
|
4205
|
-
|
4224
|
+
try {
|
4225
|
+
if (!err.stack) {
|
4226
|
+
err.stack = stack;
|
4227
|
+
// match without the 2 top stack lines
|
4228
|
+
} else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ''))) {
|
4229
|
+
err.stack += '\n' + stack;
|
4230
|
+
}
|
4231
|
+
} catch (e) {
|
4232
|
+
// ignore the case where "stack" is an un-writable property
|
4206
4233
|
}
|
4207
4234
|
}
|
4208
4235
|
|