mirror of
https://github.com/tenrok/axios.git
synced 2026-06-17 19:21:29 +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
+84
-65
@@ -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
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
||||
typeof define === 'function' && define.amd ? define(factory) :
|
||||
@@ -3093,38 +3093,42 @@
|
||||
};
|
||||
|
||||
var composeSignals = function composeSignals(signals, timeout) {
|
||||
var controller = new AbortController();
|
||||
var aborted;
|
||||
var onabort = function onabort(cancel) {
|
||||
if (!aborted) {
|
||||
aborted = true;
|
||||
unsubscribe();
|
||||
var err = cancel instanceof Error ? cancel : this.reason;
|
||||
controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err));
|
||||
}
|
||||
};
|
||||
var timer = timeout && setTimeout(function () {
|
||||
onabort(new AxiosError("timeout ".concat(timeout, " of ms exceeded"), AxiosError.ETIMEDOUT));
|
||||
}, timeout);
|
||||
var unsubscribe = function unsubscribe() {
|
||||
if (signals) {
|
||||
timer && clearTimeout(timer);
|
||||
var _signals = signals = signals ? signals.filter(Boolean) : [],
|
||||
length = _signals.length;
|
||||
if (timeout || length) {
|
||||
var controller = new AbortController();
|
||||
var aborted;
|
||||
var onabort = function onabort(reason) {
|
||||
if (!aborted) {
|
||||
aborted = true;
|
||||
unsubscribe();
|
||||
var err = reason instanceof Error ? reason : this.reason;
|
||||
controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err));
|
||||
}
|
||||
};
|
||||
var timer = timeout && setTimeout(function () {
|
||||
timer = null;
|
||||
signals.forEach(function (signal) {
|
||||
signal && (signal.removeEventListener ? signal.removeEventListener('abort', onabort) : signal.unsubscribe(onabort));
|
||||
});
|
||||
signals = null;
|
||||
}
|
||||
};
|
||||
signals.forEach(function (signal) {
|
||||
return signal && signal.addEventListener && signal.addEventListener('abort', onabort);
|
||||
});
|
||||
var signal = controller.signal;
|
||||
signal.unsubscribe = unsubscribe;
|
||||
return [signal, function () {
|
||||
timer && clearTimeout(timer);
|
||||
timer = null;
|
||||
}];
|
||||
onabort(new AxiosError("timeout ".concat(timeout, " of ms exceeded"), AxiosError.ETIMEDOUT));
|
||||
}, timeout);
|
||||
var unsubscribe = function unsubscribe() {
|
||||
if (signals) {
|
||||
timer && clearTimeout(timer);
|
||||
timer = null;
|
||||
signals.forEach(function (signal) {
|
||||
signal.unsubscribe ? signal.unsubscribe(onabort) : signal.removeEventListener('abort', onabort);
|
||||
});
|
||||
signals = null;
|
||||
}
|
||||
};
|
||||
signals.forEach(function (signal) {
|
||||
return signal.addEventListener('abort', onabort);
|
||||
});
|
||||
var signal = controller.signal;
|
||||
signal.unsubscribe = function () {
|
||||
return utils$1.asap(unsubscribe);
|
||||
};
|
||||
return signal;
|
||||
}
|
||||
};
|
||||
var composeSignals$1 = composeSignals;
|
||||
|
||||
@@ -3377,6 +3381,7 @@
|
||||
}(new Response());
|
||||
var getBodyLength = /*#__PURE__*/function () {
|
||||
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(body) {
|
||||
var _request;
|
||||
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
||||
while (1) switch (_context2.prev = _context2.next) {
|
||||
case 0:
|
||||
@@ -3393,32 +3398,36 @@
|
||||
return _context2.abrupt("return", body.size);
|
||||
case 4:
|
||||
if (!utils$1.isSpecCompliantForm(body)) {
|
||||
_context2.next = 8;
|
||||
_context2.next = 9;
|
||||
break;
|
||||
}
|
||||
_context2.next = 7;
|
||||
return new Request(body).arrayBuffer();
|
||||
case 7:
|
||||
return _context2.abrupt("return", _context2.sent.byteLength);
|
||||
_request = new Request(platform.origin, {
|
||||
method: 'POST',
|
||||
body: body
|
||||
});
|
||||
_context2.next = 8;
|
||||
return _request.arrayBuffer();
|
||||
case 8:
|
||||
return _context2.abrupt("return", _context2.sent.byteLength);
|
||||
case 9:
|
||||
if (!(utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body))) {
|
||||
_context2.next = 10;
|
||||
_context2.next = 11;
|
||||
break;
|
||||
}
|
||||
return _context2.abrupt("return", body.byteLength);
|
||||
case 10:
|
||||
case 11:
|
||||
if (utils$1.isURLSearchParams(body)) {
|
||||
body = body + '';
|
||||
}
|
||||
if (!utils$1.isString(body)) {
|
||||
_context2.next = 15;
|
||||
_context2.next = 16;
|
||||
break;
|
||||
}
|
||||
_context2.next = 14;
|
||||
_context2.next = 15;
|
||||
return encodeText(body);
|
||||
case 14:
|
||||
return _context2.abrupt("return", _context2.sent.byteLength);
|
||||
case 15:
|
||||
return _context2.abrupt("return", _context2.sent.byteLength);
|
||||
case 16:
|
||||
case "end":
|
||||
return _context2.stop();
|
||||
}
|
||||
@@ -3448,18 +3457,15 @@
|
||||
}();
|
||||
var fetchAdapter = isFetchSupported && ( /*#__PURE__*/function () {
|
||||
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(config) {
|
||||
var _resolveConfig, url, method, data, signal, cancelToken, timeout, onDownloadProgress, onUploadProgress, responseType, headers, _resolveConfig$withCr, withCredentials, fetchOptions, _ref5, _ref6, composedSignal, stopTimeout, finished, request, onFinish, requestContentLength, _request, contentTypeHeader, _progressEventDecorat, _progressEventDecorat2, onProgress, flush, isCredentialsSupported, response, isStreamResponse, options, responseContentLength, _ref7, _ref8, _onProgress, _flush, responseData;
|
||||
var _resolveConfig, url, method, data, signal, cancelToken, timeout, onDownloadProgress, onUploadProgress, responseType, headers, _resolveConfig$withCr, withCredentials, fetchOptions, composedSignal, request, unsubscribe, requestContentLength, _request, contentTypeHeader, _progressEventDecorat, _progressEventDecorat2, onProgress, flush, isCredentialsSupported, response, isStreamResponse, options, responseContentLength, _ref5, _ref6, _onProgress, _flush, responseData;
|
||||
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
||||
while (1) switch (_context4.prev = _context4.next) {
|
||||
case 0:
|
||||
_resolveConfig = resolveConfig(config), url = _resolveConfig.url, method = _resolveConfig.method, data = _resolveConfig.data, signal = _resolveConfig.signal, cancelToken = _resolveConfig.cancelToken, timeout = _resolveConfig.timeout, onDownloadProgress = _resolveConfig.onDownloadProgress, onUploadProgress = _resolveConfig.onUploadProgress, responseType = _resolveConfig.responseType, headers = _resolveConfig.headers, _resolveConfig$withCr = _resolveConfig.withCredentials, withCredentials = _resolveConfig$withCr === void 0 ? 'same-origin' : _resolveConfig$withCr, fetchOptions = _resolveConfig.fetchOptions;
|
||||
responseType = responseType ? (responseType + '').toLowerCase() : 'text';
|
||||
_ref5 = signal || cancelToken || timeout ? composeSignals$1([signal, cancelToken], timeout) : [], _ref6 = _slicedToArray(_ref5, 2), composedSignal = _ref6[0], stopTimeout = _ref6[1];
|
||||
onFinish = function onFinish() {
|
||||
!finished && setTimeout(function () {
|
||||
composedSignal && composedSignal.unsubscribe();
|
||||
});
|
||||
finished = true;
|
||||
composedSignal = composeSignals$1([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
|
||||
unsubscribe = composedSignal && composedSignal.unsubscribe && function () {
|
||||
composedSignal.unsubscribe();
|
||||
};
|
||||
_context4.prev = 4;
|
||||
_context4.t0 = onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head';
|
||||
@@ -3510,16 +3516,16 @@
|
||||
case 20:
|
||||
response = _context4.sent;
|
||||
isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
|
||||
if (supportsResponseStream && (onDownloadProgress || isStreamResponse)) {
|
||||
if (supportsResponseStream && (onDownloadProgress || isStreamResponse && unsubscribe)) {
|
||||
options = {};
|
||||
['status', 'statusText', 'headers'].forEach(function (prop) {
|
||||
options[prop] = response[prop];
|
||||
});
|
||||
responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
|
||||
_ref7 = onDownloadProgress && progressEventDecorator(responseContentLength, progressEventReducer(asyncDecorator(onDownloadProgress), true)) || [], _ref8 = _slicedToArray(_ref7, 2), _onProgress = _ref8[0], _flush = _ref8[1];
|
||||
_ref5 = onDownloadProgress && progressEventDecorator(responseContentLength, progressEventReducer(asyncDecorator(onDownloadProgress), true)) || [], _ref6 = _slicedToArray(_ref5, 2), _onProgress = _ref6[0], _flush = _ref6[1];
|
||||
response = new Response(trackStream(response.body, DEFAULT_CHUNK_SIZE, _onProgress, function () {
|
||||
_flush && _flush();
|
||||
isStreamResponse && onFinish();
|
||||
unsubscribe && unsubscribe();
|
||||
}, encodeText), options);
|
||||
}
|
||||
responseType = responseType || 'text';
|
||||
@@ -3527,9 +3533,8 @@
|
||||
return resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
|
||||
case 26:
|
||||
responseData = _context4.sent;
|
||||
!isStreamResponse && onFinish();
|
||||
stopTimeout && stopTimeout();
|
||||
_context4.next = 31;
|
||||
!isStreamResponse && unsubscribe && unsubscribe();
|
||||
_context4.next = 30;
|
||||
return new Promise(function (resolve, reject) {
|
||||
settle(resolve, reject, {
|
||||
data: responseData,
|
||||
@@ -3540,26 +3545,26 @@
|
||||
request: request
|
||||
});
|
||||
});
|
||||
case 31:
|
||||
case 30:
|
||||
return _context4.abrupt("return", _context4.sent);
|
||||
case 34:
|
||||
_context4.prev = 34;
|
||||
case 33:
|
||||
_context4.prev = 33;
|
||||
_context4.t2 = _context4["catch"](4);
|
||||
onFinish();
|
||||
unsubscribe && unsubscribe();
|
||||
if (!(_context4.t2 && _context4.t2.name === 'TypeError' && /fetch/i.test(_context4.t2.message))) {
|
||||
_context4.next = 39;
|
||||
_context4.next = 38;
|
||||
break;
|
||||
}
|
||||
throw Object.assign(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request), {
|
||||
cause: _context4.t2.cause || _context4.t2
|
||||
});
|
||||
case 39:
|
||||
case 38:
|
||||
throw AxiosError.from(_context4.t2, _context4.t2 && _context4.t2.code, config, request);
|
||||
case 40:
|
||||
case 39:
|
||||
case "end":
|
||||
return _context4.stop();
|
||||
}
|
||||
}, _callee4, null, [[4, 34]]);
|
||||
}, _callee4, null, [[4, 33]]);
|
||||
}));
|
||||
return function (_x5) {
|
||||
return _ref4.apply(this, arguments);
|
||||
@@ -3683,7 +3688,7 @@
|
||||
});
|
||||
}
|
||||
|
||||
var VERSION = "1.7.5";
|
||||
var VERSION = "1.7.6";
|
||||
|
||||
var validators$1 = {};
|
||||
|
||||
@@ -4064,6 +4069,20 @@
|
||||
this._listeners.splice(index, 1);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "toAbortSignal",
|
||||
value: function toAbortSignal() {
|
||||
var _this = this;
|
||||
var controller = new AbortController();
|
||||
var abort = function abort(err) {
|
||||
controller.abort(err);
|
||||
};
|
||||
this.subscribe(abort);
|
||||
controller.signal.unsubscribe = function () {
|
||||
return _this.unsubscribe(abort);
|
||||
};
|
||||
return controller.signal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an object that contains a new `CancelToken` and a function that, when called,
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
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';
|
||||
|
||||
function bind(fn, thisArg) {
|
||||
@@ -2637,45 +2637,46 @@ var 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;
|
||||
}
|
||||
};
|
||||
|
||||
var composeSignals$1 = composeSignals;
|
||||
@@ -2808,7 +2809,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)) {
|
||||
@@ -2848,18 +2853,13 @@ var 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;
|
||||
|
||||
@@ -2896,7 +2896,7 @@ var 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,
|
||||
@@ -2911,7 +2911,7 @@ var 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 => {
|
||||
@@ -2928,7 +2928,7 @@ var fetchAdapter = isFetchSupported && (async (config) => {
|
||||
response = new Response(
|
||||
trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
|
||||
flush && flush();
|
||||
isStreamResponse && onFinish();
|
||||
unsubscribe && unsubscribe();
|
||||
}, encodeText),
|
||||
options
|
||||
);
|
||||
@@ -2938,9 +2938,7 @@ var 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, {
|
||||
@@ -2953,7 +2951,7 @@ var fetchAdapter = isFetchSupported && (async (config) => {
|
||||
});
|
||||
})
|
||||
} catch (err) {
|
||||
onFinish();
|
||||
unsubscribe && unsubscribe();
|
||||
|
||||
if (err && err.name === 'TypeError' && /fetch/i.test(err.message)) {
|
||||
throw Object.assign(
|
||||
@@ -3115,7 +3113,7 @@ function dispatchRequest(config) {
|
||||
});
|
||||
}
|
||||
|
||||
const VERSION = "1.7.5";
|
||||
const VERSION = "1.7.6";
|
||||
|
||||
const validators$1 = {};
|
||||
|
||||
@@ -3522,6 +3520,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
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
|
||||
function bind(fn, thisArg) {
|
||||
return function wrap() {
|
||||
return fn.apply(thisArg, arguments);
|
||||
@@ -2635,45 +2635,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$1 ? err : new CanceledError$1(err instanceof Error ? err.message : err));
|
||||
}
|
||||
};
|
||||
let aborted;
|
||||
|
||||
let timer = timeout && setTimeout(() => {
|
||||
onabort(new AxiosError$1(`timeout ${timeout} of ms exceeded`, AxiosError$1.ETIMEDOUT));
|
||||
}, timeout);
|
||||
const onabort = function (reason) {
|
||||
if (!aborted) {
|
||||
aborted = true;
|
||||
unsubscribe();
|
||||
const err = reason instanceof Error ? reason : this.reason;
|
||||
controller.abort(err instanceof AxiosError$1 ? err : new CanceledError$1(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$1(`timeout ${timeout} of ms exceeded`, AxiosError$1.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;
|
||||
@@ -2806,7 +2807,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)) {
|
||||
@@ -2846,18 +2851,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;
|
||||
|
||||
@@ -2894,7 +2894,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,
|
||||
@@ -2909,7 +2909,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 => {
|
||||
@@ -2926,7 +2926,7 @@ const fetchAdapter = isFetchSupported && (async (config) => {
|
||||
response = new Response(
|
||||
trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
|
||||
flush && flush();
|
||||
isStreamResponse && onFinish();
|
||||
unsubscribe && unsubscribe();
|
||||
}, encodeText),
|
||||
options
|
||||
);
|
||||
@@ -2936,9 +2936,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, {
|
||||
@@ -2951,7 +2949,7 @@ const fetchAdapter = isFetchSupported && (async (config) => {
|
||||
});
|
||||
})
|
||||
} catch (err) {
|
||||
onFinish();
|
||||
unsubscribe && unsubscribe();
|
||||
|
||||
if (err && err.name === 'TypeError' && /fetch/i.test(err.message)) {
|
||||
throw Object.assign(
|
||||
@@ -3113,7 +3111,7 @@ function dispatchRequest(config) {
|
||||
});
|
||||
}
|
||||
|
||||
const VERSION$1 = "1.7.5";
|
||||
const VERSION$1 = "1.7.6";
|
||||
|
||||
const validators$1 = {};
|
||||
|
||||
@@ -3520,6 +3518,20 @@ class CancelToken$1 {
|
||||
}
|
||||
}
|
||||
|
||||
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
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
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