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/esm/axios.js
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
|
function bind(fn, thisArg) {
|
3
3
|
return function wrap() {
|
4
4
|
return fn.apply(thisArg, arguments);
|
@@ -2679,8 +2679,9 @@ const fetchProgressDecorator = (total, fn) => {
|
|
2679
2679
|
};
|
2680
2680
|
|
2681
2681
|
const isFetchSupported = typeof fetch !== 'undefined';
|
2682
|
+
const isReadableStreamSupported = isFetchSupported && typeof ReadableStream !== 'undefined';
|
2682
2683
|
|
2683
|
-
const
|
2684
|
+
const supportsRequestStream = isReadableStreamSupported && (() => {
|
2684
2685
|
let duplexAccessed = false;
|
2685
2686
|
|
2686
2687
|
const hasContentType = new Request(platform.origin, {
|
@@ -2697,17 +2698,32 @@ const supportsRequestStreams = isFetchSupported && (() => {
|
|
2697
2698
|
|
2698
2699
|
const DEFAULT_CHUNK_SIZE = 64 * 1024;
|
2699
2700
|
|
2701
|
+
const supportsResponseStream = isReadableStreamSupported && !!(()=> {
|
2702
|
+
try {
|
2703
|
+
return utils$1.isReadableStream(new Response('').body);
|
2704
|
+
} catch(err) {
|
2705
|
+
// return undefined
|
2706
|
+
}
|
2707
|
+
})();
|
2708
|
+
|
2700
2709
|
const resolvers = {
|
2701
|
-
stream: (res) => res.body
|
2710
|
+
stream: supportsResponseStream && ((res) => res.body)
|
2702
2711
|
};
|
2703
2712
|
|
2704
|
-
isFetchSupported &&
|
2705
|
-
|
2706
|
-
|
2707
|
-
|
2708
|
-
|
2713
|
+
isFetchSupported && (((res) => {
|
2714
|
+
['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(type => {
|
2715
|
+
!resolvers[type] && (resolvers[type] = utils$1.isFunction(res[type]) ? (res) => res[type]() :
|
2716
|
+
(_, config) => {
|
2717
|
+
throw new AxiosError$1(`Response type '${type}' is not supported`, AxiosError$1.ERR_NOT_SUPPORT, config);
|
2718
|
+
});
|
2719
|
+
});
|
2720
|
+
})(new Response));
|
2709
2721
|
|
2710
2722
|
const getBodyLength = async (body) => {
|
2723
|
+
if (body == null) {
|
2724
|
+
return 0;
|
2725
|
+
}
|
2726
|
+
|
2711
2727
|
if(utils$1.isBlob(body)) {
|
2712
2728
|
return body.size;
|
2713
2729
|
}
|
@@ -2735,7 +2751,7 @@ const resolveBodyLength = async (headers, body) => {
|
|
2735
2751
|
return length == null ? getBodyLength(body) : length;
|
2736
2752
|
};
|
2737
2753
|
|
2738
|
-
const fetchAdapter = async (config) => {
|
2754
|
+
const fetchAdapter = isFetchSupported && (async (config) => {
|
2739
2755
|
let {
|
2740
2756
|
url,
|
2741
2757
|
method,
|
@@ -2766,12 +2782,15 @@ const fetchAdapter = async (config) => {
|
|
2766
2782
|
finished = true;
|
2767
2783
|
};
|
2768
2784
|
|
2769
|
-
|
2770
|
-
if (onUploadProgress && supportsRequestStreams && method !== 'get' && method !== 'head') {
|
2771
|
-
let requestContentLength = await resolveBodyLength(headers, data);
|
2785
|
+
let requestContentLength;
|
2772
2786
|
|
2787
|
+
try {
|
2788
|
+
if (
|
2789
|
+
onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head' &&
|
2790
|
+
(requestContentLength = await resolveBodyLength(headers, data)) !== 0
|
2791
|
+
) {
|
2773
2792
|
let _request = new Request(url, {
|
2774
|
-
method,
|
2793
|
+
method: 'POST',
|
2775
2794
|
body: data,
|
2776
2795
|
duplex: "half"
|
2777
2796
|
});
|
@@ -2782,10 +2801,12 @@ const fetchAdapter = async (config) => {
|
|
2782
2801
|
headers.setContentType(contentTypeHeader);
|
2783
2802
|
}
|
2784
2803
|
|
2785
|
-
|
2786
|
-
|
2787
|
-
|
2788
|
-
|
2804
|
+
if (_request.body) {
|
2805
|
+
data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, fetchProgressDecorator(
|
2806
|
+
requestContentLength,
|
2807
|
+
progressEventReducer(onUploadProgress)
|
2808
|
+
));
|
2809
|
+
}
|
2789
2810
|
}
|
2790
2811
|
|
2791
2812
|
if (!utils$1.isString(withCredentials)) {
|
@@ -2795,7 +2816,7 @@ const fetchAdapter = async (config) => {
|
|
2795
2816
|
request = new Request(url, {
|
2796
2817
|
...fetchOptions,
|
2797
2818
|
signal: composedSignal,
|
2798
|
-
method,
|
2819
|
+
method: method.toUpperCase(),
|
2799
2820
|
headers: headers.normalize().toJSON(),
|
2800
2821
|
body: data,
|
2801
2822
|
duplex: "half",
|
@@ -2806,10 +2827,10 @@ const fetchAdapter = async (config) => {
|
|
2806
2827
|
|
2807
2828
|
const isStreamResponse = responseType === 'stream' || responseType === 'response';
|
2808
2829
|
|
2809
|
-
if (onDownloadProgress || isStreamResponse) {
|
2830
|
+
if (supportsResponseStream && (onDownloadProgress || isStreamResponse)) {
|
2810
2831
|
const options = {};
|
2811
2832
|
|
2812
|
-
|
2833
|
+
['status', 'statusText', 'headers'].forEach(prop => {
|
2813
2834
|
options[prop] = response[prop];
|
2814
2835
|
});
|
2815
2836
|
|
@@ -2845,15 +2866,18 @@ const fetchAdapter = async (config) => {
|
|
2845
2866
|
} catch (err) {
|
2846
2867
|
onFinish();
|
2847
2868
|
|
2848
|
-
|
2849
|
-
|
2850
|
-
|
2851
|
-
|
2869
|
+
if (err && err.name === 'TypeError' && /fetch/i.test(err.message)) {
|
2870
|
+
throw Object.assign(
|
2871
|
+
new AxiosError$1('Network Error', AxiosError$1.ERR_NETWORK, config, request),
|
2872
|
+
{
|
2873
|
+
cause: err.cause || err
|
2874
|
+
}
|
2875
|
+
)
|
2852
2876
|
}
|
2853
2877
|
|
2854
|
-
throw AxiosError$1.from(err, code, config, request);
|
2878
|
+
throw AxiosError$1.from(err, err && err.code, config, request);
|
2855
2879
|
}
|
2856
|
-
};
|
2880
|
+
});
|
2857
2881
|
|
2858
2882
|
const knownAdapters = {
|
2859
2883
|
http: httpAdapter,
|
@@ -3002,7 +3026,7 @@ function dispatchRequest(config) {
|
|
3002
3026
|
});
|
3003
3027
|
}
|
3004
3028
|
|
3005
|
-
const VERSION$1 = "1.7.0-beta.
|
3029
|
+
const VERSION$1 = "1.7.0-beta.2";
|
3006
3030
|
|
3007
3031
|
const validators$1 = {};
|
3008
3032
|
|
@@ -3128,12 +3152,15 @@ class Axios$1 {
|
|
3128
3152
|
|
3129
3153
|
// slice off the Error: ... line
|
3130
3154
|
const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, '') : '';
|
3131
|
-
|
3132
|
-
|
3133
|
-
|
3134
|
-
|
3135
|
-
|
3136
|
-
|
3155
|
+
try {
|
3156
|
+
if (!err.stack) {
|
3157
|
+
err.stack = stack;
|
3158
|
+
// match without the 2 top stack lines
|
3159
|
+
} else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ''))) {
|
3160
|
+
err.stack += '\n' + stack;
|
3161
|
+
}
|
3162
|
+
} catch (e) {
|
3163
|
+
// ignore the case where "stack" is an un-writable property
|
3137
3164
|
}
|
3138
3165
|
}
|
3139
3166
|
|