axios 1.7.0-beta.0 → 1.7.0-beta.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.
- package/CHANGELOG.md +14 -0
- package/dist/axios.js +43 -25
- 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 +42 -24
- package/dist/browser/axios.cjs.map +1 -1
- package/dist/esm/axios.js +42 -24
- 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 +42 -24
- package/dist/node/axios.cjs.map +1 -1
- package/lib/adapters/fetch.js +31 -16
- 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.1 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.1";
|
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,15 +3769,26 @@ 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) => {
|
3782
3794
|
if(utils$1.isBlob(body)) {
|
@@ -3806,7 +3818,7 @@ const resolveBodyLength = async (headers, body) => {
|
|
3806
3818
|
return length == null ? getBodyLength(body) : length;
|
3807
3819
|
};
|
3808
3820
|
|
3809
|
-
const fetchAdapter = async (config) => {
|
3821
|
+
const fetchAdapter = isFetchSupported && (async (config) => {
|
3810
3822
|
let {
|
3811
3823
|
url,
|
3812
3824
|
method,
|
@@ -3838,7 +3850,7 @@ const fetchAdapter = async (config) => {
|
|
3838
3850
|
};
|
3839
3851
|
|
3840
3852
|
try {
|
3841
|
-
if (onUploadProgress &&
|
3853
|
+
if (onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head') {
|
3842
3854
|
let requestContentLength = await resolveBodyLength(headers, data);
|
3843
3855
|
|
3844
3856
|
let _request = new Request(url, {
|
@@ -3877,7 +3889,7 @@ const fetchAdapter = async (config) => {
|
|
3877
3889
|
|
3878
3890
|
const isStreamResponse = responseType === 'stream' || responseType === 'response';
|
3879
3891
|
|
3880
|
-
if (onDownloadProgress || isStreamResponse) {
|
3892
|
+
if (supportsResponseStream && (onDownloadProgress || isStreamResponse)) {
|
3881
3893
|
const options = {};
|
3882
3894
|
|
3883
3895
|
Object.getOwnPropertyNames(response).forEach(prop => {
|
@@ -3916,15 +3928,18 @@ const fetchAdapter = async (config) => {
|
|
3916
3928
|
} catch (err) {
|
3917
3929
|
onFinish();
|
3918
3930
|
|
3919
|
-
|
3920
|
-
|
3921
|
-
|
3922
|
-
|
3931
|
+
if (err && err.name === 'TypeError' && /fetch/i.test(err.message)) {
|
3932
|
+
throw Object.assign(
|
3933
|
+
new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request),
|
3934
|
+
{
|
3935
|
+
cause: err.cause || err
|
3936
|
+
}
|
3937
|
+
)
|
3923
3938
|
}
|
3924
3939
|
|
3925
|
-
throw AxiosError.from(err, code, config, request);
|
3940
|
+
throw AxiosError.from(err, err && err.code, config, request);
|
3926
3941
|
}
|
3927
|
-
};
|
3942
|
+
});
|
3928
3943
|
|
3929
3944
|
const knownAdapters = {
|
3930
3945
|
http: httpAdapter,
|
@@ -4197,12 +4212,15 @@ class Axios {
|
|
4197
4212
|
|
4198
4213
|
// slice off the Error: ... line
|
4199
4214
|
const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, '') : '';
|
4200
|
-
|
4201
|
-
|
4202
|
-
|
4203
|
-
|
4204
|
-
|
4205
|
-
|
4215
|
+
try {
|
4216
|
+
if (!err.stack) {
|
4217
|
+
err.stack = stack;
|
4218
|
+
// match without the 2 top stack lines
|
4219
|
+
} else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ''))) {
|
4220
|
+
err.stack += '\n' + stack;
|
4221
|
+
}
|
4222
|
+
} catch (e) {
|
4223
|
+
// ignore the case where "stack" is an un-writable property
|
4206
4224
|
}
|
4207
4225
|
}
|
4208
4226
|
|