mirror of
https://github.com/tenrok/axios.git
synced 2026-06-08 17:22:34 +03:00
chore(release): v1.7.6 (#6583)
Co-authored-by: DigitalBrainJS <12586868+DigitalBrainJS@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
bc03c6cbc4
commit
d584fcfa62
Vendored
+62
-50
@@ -1,4 +1,4 @@
|
||||
// Axios v1.7.5 Copyright (c) 2024 Matt Zabriskie and contributors
|
||||
// Axios v1.7.6 Copyright (c) 2024 Matt Zabriskie and contributors
|
||||
'use strict';
|
||||
|
||||
const FormData$1 = require('form-data');
|
||||
@@ -2071,7 +2071,7 @@ function buildFullPath(baseURL, requestedURL) {
|
||||
return requestedURL;
|
||||
}
|
||||
|
||||
const VERSION = "1.7.5";
|
||||
const VERSION = "1.7.6";
|
||||
|
||||
function parseProtocol(url) {
|
||||
const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
|
||||
@@ -3668,45 +3668,46 @@ const xhrAdapter = isXHRAdapterSupported && function (config) {
|
||||
};
|
||||
|
||||
const composeSignals = (signals, timeout) => {
|
||||
let controller = new AbortController();
|
||||
const {length} = (signals = signals ? signals.filter(Boolean) : []);
|
||||
|
||||
let aborted;
|
||||
if (timeout || length) {
|
||||
let controller = new AbortController();
|
||||
|
||||
const onabort = function (cancel) {
|
||||
if (!aborted) {
|
||||
aborted = true;
|
||||
unsubscribe();
|
||||
const err = cancel instanceof Error ? cancel : this.reason;
|
||||
controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err));
|
||||
}
|
||||
};
|
||||
let aborted;
|
||||
|
||||
let timer = timeout && setTimeout(() => {
|
||||
onabort(new AxiosError(`timeout ${timeout} of ms exceeded`, AxiosError.ETIMEDOUT));
|
||||
}, timeout);
|
||||
const onabort = function (reason) {
|
||||
if (!aborted) {
|
||||
aborted = true;
|
||||
unsubscribe();
|
||||
const err = reason instanceof Error ? reason : this.reason;
|
||||
controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err));
|
||||
}
|
||||
};
|
||||
|
||||
const unsubscribe = () => {
|
||||
if (signals) {
|
||||
timer && clearTimeout(timer);
|
||||
let timer = timeout && setTimeout(() => {
|
||||
timer = null;
|
||||
signals.forEach(signal => {
|
||||
signal &&
|
||||
(signal.removeEventListener ? signal.removeEventListener('abort', onabort) : signal.unsubscribe(onabort));
|
||||
});
|
||||
signals = null;
|
||||
}
|
||||
};
|
||||
onabort(new AxiosError(`timeout ${timeout} of ms exceeded`, AxiosError.ETIMEDOUT));
|
||||
}, timeout);
|
||||
|
||||
signals.forEach((signal) => signal && signal.addEventListener && signal.addEventListener('abort', onabort));
|
||||
const unsubscribe = () => {
|
||||
if (signals) {
|
||||
timer && clearTimeout(timer);
|
||||
timer = null;
|
||||
signals.forEach(signal => {
|
||||
signal.unsubscribe ? signal.unsubscribe(onabort) : signal.removeEventListener('abort', onabort);
|
||||
});
|
||||
signals = null;
|
||||
}
|
||||
};
|
||||
|
||||
const {signal} = controller;
|
||||
signals.forEach((signal) => signal.addEventListener('abort', onabort));
|
||||
|
||||
signal.unsubscribe = unsubscribe;
|
||||
const {signal} = controller;
|
||||
|
||||
return [signal, () => {
|
||||
timer && clearTimeout(timer);
|
||||
timer = null;
|
||||
}];
|
||||
signal.unsubscribe = () => utils$1.asap(unsubscribe);
|
||||
|
||||
return signal;
|
||||
}
|
||||
};
|
||||
|
||||
const composeSignals$1 = composeSignals;
|
||||
@@ -3839,7 +3840,11 @@ const getBodyLength = async (body) => {
|
||||
}
|
||||
|
||||
if(utils$1.isSpecCompliantForm(body)) {
|
||||
return (await new Request(body).arrayBuffer()).byteLength;
|
||||
const _request = new Request(platform.origin, {
|
||||
method: 'POST',
|
||||
body,
|
||||
});
|
||||
return (await _request.arrayBuffer()).byteLength;
|
||||
}
|
||||
|
||||
if(utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
|
||||
@@ -3879,18 +3884,13 @@ const fetchAdapter = isFetchSupported && (async (config) => {
|
||||
|
||||
responseType = responseType ? (responseType + '').toLowerCase() : 'text';
|
||||
|
||||
let [composedSignal, stopTimeout] = (signal || cancelToken || timeout) ?
|
||||
composeSignals$1([signal, cancelToken], timeout) : [];
|
||||
let composedSignal = composeSignals$1([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
|
||||
|
||||
let finished, request;
|
||||
let request;
|
||||
|
||||
const onFinish = () => {
|
||||
!finished && setTimeout(() => {
|
||||
composedSignal && composedSignal.unsubscribe();
|
||||
});
|
||||
|
||||
finished = true;
|
||||
};
|
||||
const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
|
||||
composedSignal.unsubscribe();
|
||||
});
|
||||
|
||||
let requestContentLength;
|
||||
|
||||
@@ -3927,7 +3927,7 @@ const fetchAdapter = isFetchSupported && (async (config) => {
|
||||
|
||||
// Cloudflare Workers throws when credentials are defined
|
||||
// see https://github.com/cloudflare/workerd/issues/902
|
||||
const isCredentialsSupported = "credentials" in Request.prototype;
|
||||
const isCredentialsSupported = "credentials" in Request.prototype;
|
||||
request = new Request(url, {
|
||||
...fetchOptions,
|
||||
signal: composedSignal,
|
||||
@@ -3942,7 +3942,7 @@ const fetchAdapter = isFetchSupported && (async (config) => {
|
||||
|
||||
const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
|
||||
|
||||
if (supportsResponseStream && (onDownloadProgress || isStreamResponse)) {
|
||||
if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) {
|
||||
const options = {};
|
||||
|
||||
['status', 'statusText', 'headers'].forEach(prop => {
|
||||
@@ -3959,7 +3959,7 @@ const fetchAdapter = isFetchSupported && (async (config) => {
|
||||
response = new Response(
|
||||
trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
|
||||
flush && flush();
|
||||
isStreamResponse && onFinish();
|
||||
unsubscribe && unsubscribe();
|
||||
}, encodeText),
|
||||
options
|
||||
);
|
||||
@@ -3969,9 +3969,7 @@ const fetchAdapter = isFetchSupported && (async (config) => {
|
||||
|
||||
let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
|
||||
|
||||
!isStreamResponse && onFinish();
|
||||
|
||||
stopTimeout && stopTimeout();
|
||||
!isStreamResponse && unsubscribe && unsubscribe();
|
||||
|
||||
return await new Promise((resolve, reject) => {
|
||||
settle(resolve, reject, {
|
||||
@@ -3984,7 +3982,7 @@ const fetchAdapter = isFetchSupported && (async (config) => {
|
||||
});
|
||||
})
|
||||
} catch (err) {
|
||||
onFinish();
|
||||
unsubscribe && unsubscribe();
|
||||
|
||||
if (err && err.name === 'TypeError' && /fetch/i.test(err.message)) {
|
||||
throw Object.assign(
|
||||
@@ -4551,6 +4549,20 @@ class CancelToken {
|
||||
}
|
||||
}
|
||||
|
||||
toAbortSignal() {
|
||||
const controller = new AbortController();
|
||||
|
||||
const abort = (err) => {
|
||||
controller.abort(err);
|
||||
};
|
||||
|
||||
this.subscribe(abort);
|
||||
|
||||
controller.signal.unsubscribe = () => this.unsubscribe(abort);
|
||||
|
||||
return controller.signal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an object that contains a new `CancelToken` and a function that, when called,
|
||||
* cancels the `CancelToken`.
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user