2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-14 18:42:33 +03:00

chore(release): v1.7.0-beta.1 (#6383)

Co-authored-by: DigitalBrainJS <DigitalBrainJS@users.noreply.github.com>
This commit is contained in:
github-actions[bot]
2024-05-07 21:37:01 +03:00
committed by GitHub
parent bb5f9a5ab7
commit b9f4848f8c
17 changed files with 197 additions and 111 deletions
+42 -24
View File
@@ -1,4 +1,4 @@
// Axios v1.7.0-beta.0 Copyright (c) 2024 Matt Zabriskie and contributors
// Axios v1.7.0-beta.1 Copyright (c) 2024 Matt Zabriskie and contributors
'use strict';
const FormData$1 = require('form-data');
@@ -2035,7 +2035,7 @@ function buildFullPath(baseURL, requestedURL) {
return requestedURL;
}
const VERSION = "1.7.0-beta.0";
const VERSION = "1.7.0-beta.1";
function parseProtocol(url) {
const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
@@ -3750,8 +3750,9 @@ const fetchProgressDecorator = (total, fn) => {
};
const isFetchSupported = typeof fetch !== 'undefined';
const isReadableStreamSupported = isFetchSupported && typeof ReadableStream !== 'undefined';
const supportsRequestStreams = isFetchSupported && (() => {
const supportsRequestStream = isReadableStreamSupported && (() => {
let duplexAccessed = false;
const hasContentType = new Request(platform.origin, {
@@ -3768,15 +3769,26 @@ const supportsRequestStreams = isFetchSupported && (() => {
const DEFAULT_CHUNK_SIZE = 64 * 1024;
const supportsResponseStream = isReadableStreamSupported && !!(()=> {
try {
return utils$1.isReadableStream(new Response('').body);
} catch(err) {
// return undefined
}
})();
const resolvers = {
stream: (res) => res.body
stream: supportsResponseStream && ((res) => res.body)
};
isFetchSupported && ['text', 'arrayBuffer', 'blob', 'formData'].forEach(type => [
resolvers[type] = utils$1.isFunction(Response.prototype[type]) ? (res) => res[type]() : (_, config) => {
throw new AxiosError(`Response type ${type} is not supported`, AxiosError.ERR_NOT_SUPPORT, config);
}
]);
isFetchSupported && (((res) => {
['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(type => {
!resolvers[type] && (resolvers[type] = utils$1.isFunction(res[type]) ? (res) => res[type]() :
(_, config) => {
throw new AxiosError(`Response type '${type}' is not supported`, AxiosError.ERR_NOT_SUPPORT, config);
});
});
})(new Response));
const getBodyLength = async (body) => {
if(utils$1.isBlob(body)) {
@@ -3806,7 +3818,7 @@ const resolveBodyLength = async (headers, body) => {
return length == null ? getBodyLength(body) : length;
};
const fetchAdapter = async (config) => {
const fetchAdapter = isFetchSupported && (async (config) => {
let {
url,
method,
@@ -3838,7 +3850,7 @@ const fetchAdapter = async (config) => {
};
try {
if (onUploadProgress && supportsRequestStreams && method !== 'get' && method !== 'head') {
if (onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head') {
let requestContentLength = await resolveBodyLength(headers, data);
let _request = new Request(url, {
@@ -3877,7 +3889,7 @@ const fetchAdapter = async (config) => {
const isStreamResponse = responseType === 'stream' || responseType === 'response';
if (onDownloadProgress || isStreamResponse) {
if (supportsResponseStream && (onDownloadProgress || isStreamResponse)) {
const options = {};
Object.getOwnPropertyNames(response).forEach(prop => {
@@ -3916,15 +3928,18 @@ const fetchAdapter = async (config) => {
} catch (err) {
onFinish();
let {code} = err;
if (err.name === 'NetworkError') {
code = AxiosError.ERR_NETWORK;
if (err && err.name === 'TypeError' && /fetch/i.test(err.message)) {
throw Object.assign(
new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request),
{
cause: err.cause || err
}
)
}
throw AxiosError.from(err, code, config, request);
throw AxiosError.from(err, err && err.code, config, request);
}
};
});
const knownAdapters = {
http: httpAdapter,
@@ -4197,12 +4212,15 @@ class Axios {
// slice off the Error: ... line
const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, '') : '';
if (!err.stack) {
err.stack = stack;
// match without the 2 top stack lines
} else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ''))) {
err.stack += '\n' + stack;
try {
if (!err.stack) {
err.stack = stack;
// match without the 2 top stack lines
} else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ''))) {
err.stack += '\n' + stack;
}
} catch (e) {
// ignore the case where "stack" is an un-writable property
}
}
+1 -1
View File
File diff suppressed because one or more lines are too long