axios 1.7.5 → 1.7.6
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/README.md +4 -3
- package/dist/axios.js +84 -65
- 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 +62 -50
- package/dist/browser/axios.cjs.map +1 -1
- package/dist/esm/axios.js +62 -50
- 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 +62 -50
- package/dist/node/axios.cjs.map +1 -1
- package/lib/adapters/fetch.js +15 -18
- package/lib/cancel/CancelToken.js +14 -0
- package/lib/env/data.js +1 -1
- package/lib/helpers/composeSignals.js +31 -29
- package/package.json +1 -1
package/dist/node/axios.cjs
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
// Axios v1.7.
|
1
|
+
// Axios v1.7.6 Copyright (c) 2024 Matt Zabriskie and contributors
|
2
2
|
'use strict';
|
3
3
|
|
4
4
|
const FormData$1 = require('form-data');
|
@@ -2071,7 +2071,7 @@ function buildFullPath(baseURL, requestedURL) {
|
|
2071
2071
|
return requestedURL;
|
2072
2072
|
}
|
2073
2073
|
|
2074
|
-
const VERSION = "1.7.
|
2074
|
+
const VERSION = "1.7.6";
|
2075
2075
|
|
2076
2076
|
function parseProtocol(url) {
|
2077
2077
|
const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
|
@@ -3668,45 +3668,46 @@ const xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
3668
3668
|
};
|
3669
3669
|
|
3670
3670
|
const composeSignals = (signals, timeout) => {
|
3671
|
-
|
3671
|
+
const {length} = (signals = signals ? signals.filter(Boolean) : []);
|
3672
3672
|
|
3673
|
-
|
3673
|
+
if (timeout || length) {
|
3674
|
+
let controller = new AbortController();
|
3674
3675
|
|
3675
|
-
|
3676
|
-
if (!aborted) {
|
3677
|
-
aborted = true;
|
3678
|
-
unsubscribe();
|
3679
|
-
const err = cancel instanceof Error ? cancel : this.reason;
|
3680
|
-
controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err));
|
3681
|
-
}
|
3682
|
-
};
|
3676
|
+
let aborted;
|
3683
3677
|
|
3684
|
-
|
3685
|
-
|
3686
|
-
|
3678
|
+
const onabort = function (reason) {
|
3679
|
+
if (!aborted) {
|
3680
|
+
aborted = true;
|
3681
|
+
unsubscribe();
|
3682
|
+
const err = reason instanceof Error ? reason : this.reason;
|
3683
|
+
controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err));
|
3684
|
+
}
|
3685
|
+
};
|
3687
3686
|
|
3688
|
-
|
3689
|
-
if (signals) {
|
3690
|
-
timer && clearTimeout(timer);
|
3687
|
+
let timer = timeout && setTimeout(() => {
|
3691
3688
|
timer = null;
|
3692
|
-
|
3693
|
-
|
3694
|
-
|
3695
|
-
|
3696
|
-
signals
|
3697
|
-
|
3698
|
-
|
3689
|
+
onabort(new AxiosError(`timeout ${timeout} of ms exceeded`, AxiosError.ETIMEDOUT));
|
3690
|
+
}, timeout);
|
3691
|
+
|
3692
|
+
const unsubscribe = () => {
|
3693
|
+
if (signals) {
|
3694
|
+
timer && clearTimeout(timer);
|
3695
|
+
timer = null;
|
3696
|
+
signals.forEach(signal => {
|
3697
|
+
signal.unsubscribe ? signal.unsubscribe(onabort) : signal.removeEventListener('abort', onabort);
|
3698
|
+
});
|
3699
|
+
signals = null;
|
3700
|
+
}
|
3701
|
+
};
|
3699
3702
|
|
3700
|
-
|
3703
|
+
signals.forEach((signal) => signal.addEventListener('abort', onabort));
|
3701
3704
|
|
3702
|
-
|
3705
|
+
const {signal} = controller;
|
3703
3706
|
|
3704
|
-
|
3707
|
+
signal.unsubscribe = () => utils$1.asap(unsubscribe);
|
3705
3708
|
|
3706
|
-
|
3707
|
-
|
3708
|
-
timer = null;
|
3709
|
-
}];
|
3709
|
+
return signal;
|
3710
|
+
}
|
3710
3711
|
};
|
3711
3712
|
|
3712
3713
|
const composeSignals$1 = composeSignals;
|
@@ -3839,7 +3840,11 @@ const getBodyLength = async (body) => {
|
|
3839
3840
|
}
|
3840
3841
|
|
3841
3842
|
if(utils$1.isSpecCompliantForm(body)) {
|
3842
|
-
|
3843
|
+
const _request = new Request(platform.origin, {
|
3844
|
+
method: 'POST',
|
3845
|
+
body,
|
3846
|
+
});
|
3847
|
+
return (await _request.arrayBuffer()).byteLength;
|
3843
3848
|
}
|
3844
3849
|
|
3845
3850
|
if(utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
|
@@ -3879,18 +3884,13 @@ const fetchAdapter = isFetchSupported && (async (config) => {
|
|
3879
3884
|
|
3880
3885
|
responseType = responseType ? (responseType + '').toLowerCase() : 'text';
|
3881
3886
|
|
3882
|
-
let
|
3883
|
-
composeSignals$1([signal, cancelToken], timeout) : [];
|
3887
|
+
let composedSignal = composeSignals$1([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
|
3884
3888
|
|
3885
|
-
let
|
3889
|
+
let request;
|
3886
3890
|
|
3887
|
-
const
|
3888
|
-
|
3889
|
-
|
3890
|
-
});
|
3891
|
-
|
3892
|
-
finished = true;
|
3893
|
-
};
|
3891
|
+
const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
|
3892
|
+
composedSignal.unsubscribe();
|
3893
|
+
});
|
3894
3894
|
|
3895
3895
|
let requestContentLength;
|
3896
3896
|
|
@@ -3927,7 +3927,7 @@ const fetchAdapter = isFetchSupported && (async (config) => {
|
|
3927
3927
|
|
3928
3928
|
// Cloudflare Workers throws when credentials are defined
|
3929
3929
|
// see https://github.com/cloudflare/workerd/issues/902
|
3930
|
-
const isCredentialsSupported = "credentials" in Request.prototype;
|
3930
|
+
const isCredentialsSupported = "credentials" in Request.prototype;
|
3931
3931
|
request = new Request(url, {
|
3932
3932
|
...fetchOptions,
|
3933
3933
|
signal: composedSignal,
|
@@ -3942,7 +3942,7 @@ const fetchAdapter = isFetchSupported && (async (config) => {
|
|
3942
3942
|
|
3943
3943
|
const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
|
3944
3944
|
|
3945
|
-
if (supportsResponseStream && (onDownloadProgress || isStreamResponse)) {
|
3945
|
+
if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) {
|
3946
3946
|
const options = {};
|
3947
3947
|
|
3948
3948
|
['status', 'statusText', 'headers'].forEach(prop => {
|
@@ -3959,7 +3959,7 @@ const fetchAdapter = isFetchSupported && (async (config) => {
|
|
3959
3959
|
response = new Response(
|
3960
3960
|
trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
|
3961
3961
|
flush && flush();
|
3962
|
-
|
3962
|
+
unsubscribe && unsubscribe();
|
3963
3963
|
}, encodeText),
|
3964
3964
|
options
|
3965
3965
|
);
|
@@ -3969,9 +3969,7 @@ const fetchAdapter = isFetchSupported && (async (config) => {
|
|
3969
3969
|
|
3970
3970
|
let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
|
3971
3971
|
|
3972
|
-
!isStreamResponse &&
|
3973
|
-
|
3974
|
-
stopTimeout && stopTimeout();
|
3972
|
+
!isStreamResponse && unsubscribe && unsubscribe();
|
3975
3973
|
|
3976
3974
|
return await new Promise((resolve, reject) => {
|
3977
3975
|
settle(resolve, reject, {
|
@@ -3984,7 +3982,7 @@ const fetchAdapter = isFetchSupported && (async (config) => {
|
|
3984
3982
|
});
|
3985
3983
|
})
|
3986
3984
|
} catch (err) {
|
3987
|
-
|
3985
|
+
unsubscribe && unsubscribe();
|
3988
3986
|
|
3989
3987
|
if (err && err.name === 'TypeError' && /fetch/i.test(err.message)) {
|
3990
3988
|
throw Object.assign(
|
@@ -4551,6 +4549,20 @@ class CancelToken {
|
|
4551
4549
|
}
|
4552
4550
|
}
|
4553
4551
|
|
4552
|
+
toAbortSignal() {
|
4553
|
+
const controller = new AbortController();
|
4554
|
+
|
4555
|
+
const abort = (err) => {
|
4556
|
+
controller.abort(err);
|
4557
|
+
};
|
4558
|
+
|
4559
|
+
this.subscribe(abort);
|
4560
|
+
|
4561
|
+
controller.signal.unsubscribe = () => this.unsubscribe(abort);
|
4562
|
+
|
4563
|
+
return controller.signal;
|
4564
|
+
}
|
4565
|
+
|
4554
4566
|
/**
|
4555
4567
|
* Returns an object that contains a new `CancelToken` and a function that, when called,
|
4556
4568
|
* cancels the `CancelToken`.
|