mirror of
https://github.com/tenrok/axios.git
synced 2026-06-08 17:22:34 +03:00
chore(release): v1.7.1 (#6411)
Co-authored-by: DigitalBrainJS <12586868+DigitalBrainJS@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
733f15fe5b
commit
67d1373131
+14
-3
@@ -1,5 +1,16 @@
|
||||
# Changelog
|
||||
|
||||
# Changelog
|
||||
|
||||
## [1.7.1](https://github.com/axios/axios/compare/v1.7.0...v1.7.1) (2024-05-20)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **fetch:** fixed ReferenceError issue when TextEncoder is not available in the environment; ([#6410](https://github.com/axios/axios/issues/6410)) ([733f15f](https://github.com/axios/axios/commit/733f15fe5bd2d67e1fadaee82e7913b70d45dc5e))
|
||||
|
||||
### Contributors to this release
|
||||
|
||||
- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+14/-9 (#6410 )")
|
||||
|
||||
# [1.7.0](https://github.com/axios/axios/compare/v1.7.0-beta.2...v1.7.0) (2024-05-19)
|
||||
|
||||
|
||||
@@ -927,4 +938,4 @@ This functionality is considered as a fix.
|
||||
- [Marco Weber](https://github.com/mrcwbr)
|
||||
- [Luca Pizzini](https://github.com/lpizzinidev)
|
||||
- [Willian Agostini](https://github.com/WillianAgostini)
|
||||
- [Huyen Nguyen](https://github.com/huyenltnguyen)
|
||||
- [Huyen Nguyen](https://github.com/huyenltnguyen)
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "axios",
|
||||
"main": "./dist/axios.js",
|
||||
"version": "1.7.0",
|
||||
"version": "1.7.1",
|
||||
"homepage": "https://axios-http.com",
|
||||
"authors": [
|
||||
"Matt Zabriskie"
|
||||
|
||||
Vendored
+100
-74
@@ -1,4 +1,4 @@
|
||||
// Axios v1.7.0 Copyright (c) 2024 Matt Zabriskie and contributors
|
||||
// Axios v1.7.1 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) :
|
||||
@@ -3085,9 +3085,8 @@
|
||||
}
|
||||
}, streamChunk);
|
||||
});
|
||||
var encoder = new TextEncoder();
|
||||
var readBytes = /*#__PURE__*/function () {
|
||||
var _ref = _wrapAsyncGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(iterable, chunkSize) {
|
||||
var _ref = _wrapAsyncGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(iterable, chunkSize, encode) {
|
||||
var _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, chunk;
|
||||
return _regeneratorRuntime().wrap(function _callee$(_context2) {
|
||||
while (1) switch (_context2.prev = _context2.next) {
|
||||
@@ -3117,7 +3116,7 @@
|
||||
break;
|
||||
case 15:
|
||||
_context2.next = 17;
|
||||
return _awaitAsyncGenerator(encoder.encode(String(chunk)));
|
||||
return _awaitAsyncGenerator(encode(String(chunk)));
|
||||
case 17:
|
||||
_context2.t3 = _context2.sent;
|
||||
case 18:
|
||||
@@ -3165,12 +3164,12 @@
|
||||
}
|
||||
}, _callee, null, [[2, 29, 33, 43], [34,, 38, 42]]);
|
||||
}));
|
||||
return function readBytes(_x, _x2) {
|
||||
return function readBytes(_x, _x2, _x3) {
|
||||
return _ref.apply(this, arguments);
|
||||
};
|
||||
}();
|
||||
var trackStream = function trackStream(stream, chunkSize, onProgress, onFinish) {
|
||||
var iterator = readBytes(stream, chunkSize);
|
||||
var trackStream = function trackStream(stream, chunkSize, onProgress, onFinish, encode) {
|
||||
var iterator = readBytes(stream, chunkSize, encode);
|
||||
var bytes = 0;
|
||||
return new ReadableStream({
|
||||
type: 'bytes',
|
||||
@@ -3227,6 +3226,33 @@
|
||||
};
|
||||
var isFetchSupported = typeof fetch !== 'undefined';
|
||||
var isReadableStreamSupported = isFetchSupported && typeof ReadableStream !== 'undefined';
|
||||
|
||||
// used only inside the fetch adapter
|
||||
var encodeText = isFetchSupported && (typeof TextEncoder !== 'undefined' ? function (encoder) {
|
||||
return function (str) {
|
||||
return encoder.encode(str);
|
||||
};
|
||||
}(new TextEncoder()) : ( /*#__PURE__*/function () {
|
||||
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(str) {
|
||||
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
||||
while (1) switch (_context.prev = _context.next) {
|
||||
case 0:
|
||||
_context.t0 = Uint8Array;
|
||||
_context.next = 3;
|
||||
return new Response(str).arrayBuffer();
|
||||
case 3:
|
||||
_context.t1 = _context.sent;
|
||||
return _context.abrupt("return", new _context.t0(_context.t1));
|
||||
case 5:
|
||||
case "end":
|
||||
return _context.stop();
|
||||
}
|
||||
}, _callee);
|
||||
}));
|
||||
return function (_x) {
|
||||
return _ref.apply(this, arguments);
|
||||
};
|
||||
}()));
|
||||
var supportsRequestStream = isReadableStreamSupported && function () {
|
||||
var duplexAccessed = false;
|
||||
var hasContentType = new Request(platform.origin, {
|
||||
@@ -3262,105 +3288,105 @@
|
||||
});
|
||||
}(new Response());
|
||||
var getBodyLength = /*#__PURE__*/function () {
|
||||
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(body) {
|
||||
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
||||
while (1) switch (_context.prev = _context.next) {
|
||||
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(body) {
|
||||
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
||||
while (1) switch (_context2.prev = _context2.next) {
|
||||
case 0:
|
||||
if (!(body == null)) {
|
||||
_context.next = 2;
|
||||
_context2.next = 2;
|
||||
break;
|
||||
}
|
||||
return _context.abrupt("return", 0);
|
||||
return _context2.abrupt("return", 0);
|
||||
case 2:
|
||||
if (!utils$1.isBlob(body)) {
|
||||
_context.next = 4;
|
||||
_context2.next = 4;
|
||||
break;
|
||||
}
|
||||
return _context.abrupt("return", body.size);
|
||||
return _context2.abrupt("return", body.size);
|
||||
case 4:
|
||||
if (!utils$1.isSpecCompliantForm(body)) {
|
||||
_context.next = 8;
|
||||
_context2.next = 8;
|
||||
break;
|
||||
}
|
||||
_context.next = 7;
|
||||
_context2.next = 7;
|
||||
return new Request(body).arrayBuffer();
|
||||
case 7:
|
||||
return _context.abrupt("return", _context.sent.byteLength);
|
||||
return _context2.abrupt("return", _context2.sent.byteLength);
|
||||
case 8:
|
||||
if (!utils$1.isArrayBufferView(body)) {
|
||||
_context.next = 10;
|
||||
_context2.next = 10;
|
||||
break;
|
||||
}
|
||||
return _context.abrupt("return", body.byteLength);
|
||||
return _context2.abrupt("return", body.byteLength);
|
||||
case 10:
|
||||
if (utils$1.isURLSearchParams(body)) {
|
||||
body = body + '';
|
||||
}
|
||||
if (!utils$1.isString(body)) {
|
||||
_context.next = 15;
|
||||
_context2.next = 15;
|
||||
break;
|
||||
}
|
||||
_context.next = 14;
|
||||
return new TextEncoder().encode(body);
|
||||
_context2.next = 14;
|
||||
return encodeText(body);
|
||||
case 14:
|
||||
return _context.abrupt("return", _context.sent.byteLength);
|
||||
return _context2.abrupt("return", _context2.sent.byteLength);
|
||||
case 15:
|
||||
case "end":
|
||||
return _context.stop();
|
||||
}
|
||||
}, _callee);
|
||||
}));
|
||||
return function getBodyLength(_x) {
|
||||
return _ref.apply(this, arguments);
|
||||
};
|
||||
}();
|
||||
var resolveBodyLength = /*#__PURE__*/function () {
|
||||
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(headers, body) {
|
||||
var length;
|
||||
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
||||
while (1) switch (_context2.prev = _context2.next) {
|
||||
case 0:
|
||||
length = utils$1.toFiniteNumber(headers.getContentLength());
|
||||
return _context2.abrupt("return", length == null ? getBodyLength(body) : length);
|
||||
case 2:
|
||||
case "end":
|
||||
return _context2.stop();
|
||||
}
|
||||
}, _callee2);
|
||||
}));
|
||||
return function resolveBodyLength(_x2, _x3) {
|
||||
return function getBodyLength(_x2) {
|
||||
return _ref2.apply(this, arguments);
|
||||
};
|
||||
}();
|
||||
var fetchAdapter = isFetchSupported && ( /*#__PURE__*/function () {
|
||||
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(config) {
|
||||
var _resolveConfig, url, method, data, signal, cancelToken, timeout, onDownloadProgress, onUploadProgress, responseType, headers, _resolveConfig$withCr, withCredentials, fetchOptions, _ref4, _ref5, composedSignal, stopTimeout, finished, request, onFinish, requestContentLength, _request, contentTypeHeader, response, isStreamResponse, options, responseContentLength, responseData;
|
||||
var resolveBodyLength = /*#__PURE__*/function () {
|
||||
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(headers, body) {
|
||||
var length;
|
||||
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
||||
while (1) switch (_context3.prev = _context3.next) {
|
||||
case 0:
|
||||
length = utils$1.toFiniteNumber(headers.getContentLength());
|
||||
return _context3.abrupt("return", length == null ? getBodyLength(body) : length);
|
||||
case 2:
|
||||
case "end":
|
||||
return _context3.stop();
|
||||
}
|
||||
}, _callee3);
|
||||
}));
|
||||
return function resolveBodyLength(_x3, _x4) {
|
||||
return _ref3.apply(this, arguments);
|
||||
};
|
||||
}();
|
||||
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, response, isStreamResponse, options, responseContentLength, 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';
|
||||
_ref4 = signal || cancelToken || timeout ? composeSignals$1([signal, cancelToken], timeout) : [], _ref5 = _slicedToArray(_ref4, 2), composedSignal = _ref5[0], stopTimeout = _ref5[1];
|
||||
_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;
|
||||
};
|
||||
_context3.prev = 4;
|
||||
_context3.t0 = onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head';
|
||||
if (!_context3.t0) {
|
||||
_context3.next = 11;
|
||||
_context4.prev = 4;
|
||||
_context4.t0 = onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head';
|
||||
if (!_context4.t0) {
|
||||
_context4.next = 11;
|
||||
break;
|
||||
}
|
||||
_context3.next = 9;
|
||||
_context4.next = 9;
|
||||
return resolveBodyLength(headers, data);
|
||||
case 9:
|
||||
_context3.t1 = requestContentLength = _context3.sent;
|
||||
_context3.t0 = _context3.t1 !== 0;
|
||||
_context4.t1 = requestContentLength = _context4.sent;
|
||||
_context4.t0 = _context4.t1 !== 0;
|
||||
case 11:
|
||||
if (!_context3.t0) {
|
||||
_context3.next = 15;
|
||||
if (!_context4.t0) {
|
||||
_context4.next = 15;
|
||||
break;
|
||||
}
|
||||
_request = new Request(url, {
|
||||
@@ -3372,7 +3398,7 @@
|
||||
headers.setContentType(contentTypeHeader);
|
||||
}
|
||||
if (_request.body) {
|
||||
data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, fetchProgressDecorator(requestContentLength, progressEventReducer(onUploadProgress)));
|
||||
data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, fetchProgressDecorator(requestContentLength, progressEventReducer(onUploadProgress)), null, encodeText);
|
||||
}
|
||||
case 15:
|
||||
if (!utils$1.isString(withCredentials)) {
|
||||
@@ -3386,10 +3412,10 @@
|
||||
duplex: "half",
|
||||
withCredentials: withCredentials
|
||||
}));
|
||||
_context3.next = 19;
|
||||
_context4.next = 19;
|
||||
return fetch(request);
|
||||
case 19:
|
||||
response = _context3.sent;
|
||||
response = _context4.sent;
|
||||
isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
|
||||
if (supportsResponseStream && (onDownloadProgress || isStreamResponse)) {
|
||||
options = {};
|
||||
@@ -3397,16 +3423,16 @@
|
||||
options[prop] = response[prop];
|
||||
});
|
||||
responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
|
||||
response = new Response(trackStream(response.body, DEFAULT_CHUNK_SIZE, onDownloadProgress && fetchProgressDecorator(responseContentLength, progressEventReducer(onDownloadProgress, true)), isStreamResponse && onFinish), options);
|
||||
response = new Response(trackStream(response.body, DEFAULT_CHUNK_SIZE, onDownloadProgress && fetchProgressDecorator(responseContentLength, progressEventReducer(onDownloadProgress, true)), isStreamResponse && onFinish, encodeText), options);
|
||||
}
|
||||
responseType = responseType || 'text';
|
||||
_context3.next = 25;
|
||||
_context4.next = 25;
|
||||
return resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
|
||||
case 25:
|
||||
responseData = _context3.sent;
|
||||
responseData = _context4.sent;
|
||||
!isStreamResponse && onFinish();
|
||||
stopTimeout && stopTimeout();
|
||||
_context3.next = 30;
|
||||
_context4.next = 30;
|
||||
return new Promise(function (resolve, reject) {
|
||||
settle(resolve, reject, {
|
||||
data: responseData,
|
||||
@@ -3418,28 +3444,28 @@
|
||||
});
|
||||
});
|
||||
case 30:
|
||||
return _context3.abrupt("return", _context3.sent);
|
||||
return _context4.abrupt("return", _context4.sent);
|
||||
case 33:
|
||||
_context3.prev = 33;
|
||||
_context3.t2 = _context3["catch"](4);
|
||||
_context4.prev = 33;
|
||||
_context4.t2 = _context4["catch"](4);
|
||||
onFinish();
|
||||
if (!(_context3.t2 && _context3.t2.name === 'TypeError' && /fetch/i.test(_context3.t2.message))) {
|
||||
_context3.next = 38;
|
||||
if (!(_context4.t2 && _context4.t2.name === 'TypeError' && /fetch/i.test(_context4.t2.message))) {
|
||||
_context4.next = 38;
|
||||
break;
|
||||
}
|
||||
throw Object.assign(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request), {
|
||||
cause: _context3.t2.cause || _context3.t2
|
||||
cause: _context4.t2.cause || _context4.t2
|
||||
});
|
||||
case 38:
|
||||
throw AxiosError.from(_context3.t2, _context3.t2 && _context3.t2.code, config, request);
|
||||
throw AxiosError.from(_context4.t2, _context4.t2 && _context4.t2.code, config, request);
|
||||
case 39:
|
||||
case "end":
|
||||
return _context3.stop();
|
||||
return _context4.stop();
|
||||
}
|
||||
}, _callee3, null, [[4, 33]]);
|
||||
}, _callee4, null, [[4, 33]]);
|
||||
}));
|
||||
return function (_x4) {
|
||||
return _ref3.apply(this, arguments);
|
||||
return function (_x5) {
|
||||
return _ref4.apply(this, arguments);
|
||||
};
|
||||
}());
|
||||
|
||||
@@ -3560,7 +3586,7 @@
|
||||
});
|
||||
}
|
||||
|
||||
var VERSION = "1.7.0";
|
||||
var VERSION = "1.7.1";
|
||||
|
||||
var validators$1 = {};
|
||||
|
||||
|
||||
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
+15
-11
@@ -1,4 +1,4 @@
|
||||
// Axios v1.7.0 Copyright (c) 2024 Matt Zabriskie and contributors
|
||||
// Axios v1.7.1 Copyright (c) 2024 Matt Zabriskie and contributors
|
||||
'use strict';
|
||||
|
||||
function bind(fn, thisArg) {
|
||||
@@ -2633,16 +2633,14 @@ const streamChunk = function* (chunk, chunkSize) {
|
||||
}
|
||||
};
|
||||
|
||||
const encoder = new TextEncoder();
|
||||
|
||||
const readBytes = async function* (iterable, chunkSize) {
|
||||
const readBytes = async function* (iterable, chunkSize, encode) {
|
||||
for await (const chunk of iterable) {
|
||||
yield* streamChunk(ArrayBuffer.isView(chunk) ? chunk : (await encoder.encode(String(chunk))), chunkSize);
|
||||
yield* streamChunk(ArrayBuffer.isView(chunk) ? chunk : (await encode(String(chunk))), chunkSize);
|
||||
}
|
||||
};
|
||||
|
||||
const trackStream = (stream, chunkSize, onProgress, onFinish) => {
|
||||
const iterator = readBytes(stream, chunkSize);
|
||||
const trackStream = (stream, chunkSize, onProgress, onFinish, encode) => {
|
||||
const iterator = readBytes(stream, chunkSize, encode);
|
||||
|
||||
let bytes = 0;
|
||||
|
||||
@@ -2683,6 +2681,12 @@ const fetchProgressDecorator = (total, fn) => {
|
||||
const isFetchSupported = typeof fetch !== 'undefined';
|
||||
const isReadableStreamSupported = isFetchSupported && typeof ReadableStream !== 'undefined';
|
||||
|
||||
// used only inside the fetch adapter
|
||||
const encodeText = isFetchSupported && (typeof TextEncoder !== 'undefined' ?
|
||||
((encoder) => (str) => encoder.encode(str))(new TextEncoder()) :
|
||||
async (str) => new Uint8Array(await new Response(str).arrayBuffer())
|
||||
);
|
||||
|
||||
const supportsRequestStream = isReadableStreamSupported && (() => {
|
||||
let duplexAccessed = false;
|
||||
|
||||
@@ -2743,7 +2747,7 @@ const getBodyLength = async (body) => {
|
||||
}
|
||||
|
||||
if(utils$1.isString(body)) {
|
||||
return (await new TextEncoder().encode(body)).byteLength;
|
||||
return (await encodeText(body)).byteLength;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2807,7 +2811,7 @@ var fetchAdapter = isFetchSupported && (async (config) => {
|
||||
data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, fetchProgressDecorator(
|
||||
requestContentLength,
|
||||
progressEventReducer(onUploadProgress)
|
||||
));
|
||||
), null, encodeText);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2842,7 +2846,7 @@ var fetchAdapter = isFetchSupported && (async (config) => {
|
||||
trackStream(response.body, DEFAULT_CHUNK_SIZE, onDownloadProgress && fetchProgressDecorator(
|
||||
responseContentLength,
|
||||
progressEventReducer(onDownloadProgress, true)
|
||||
), isStreamResponse && onFinish),
|
||||
), isStreamResponse && onFinish, encodeText),
|
||||
options
|
||||
);
|
||||
}
|
||||
@@ -3028,7 +3032,7 @@ function dispatchRequest(config) {
|
||||
});
|
||||
}
|
||||
|
||||
const VERSION = "1.7.0";
|
||||
const VERSION = "1.7.1";
|
||||
|
||||
const validators$1 = {};
|
||||
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+15
-11
@@ -1,4 +1,4 @@
|
||||
// Axios v1.7.0 Copyright (c) 2024 Matt Zabriskie and contributors
|
||||
// Axios v1.7.1 Copyright (c) 2024 Matt Zabriskie and contributors
|
||||
function bind(fn, thisArg) {
|
||||
return function wrap() {
|
||||
return fn.apply(thisArg, arguments);
|
||||
@@ -2631,16 +2631,14 @@ const streamChunk = function* (chunk, chunkSize) {
|
||||
}
|
||||
};
|
||||
|
||||
const encoder = new TextEncoder();
|
||||
|
||||
const readBytes = async function* (iterable, chunkSize) {
|
||||
const readBytes = async function* (iterable, chunkSize, encode) {
|
||||
for await (const chunk of iterable) {
|
||||
yield* streamChunk(ArrayBuffer.isView(chunk) ? chunk : (await encoder.encode(String(chunk))), chunkSize);
|
||||
yield* streamChunk(ArrayBuffer.isView(chunk) ? chunk : (await encode(String(chunk))), chunkSize);
|
||||
}
|
||||
};
|
||||
|
||||
const trackStream = (stream, chunkSize, onProgress, onFinish) => {
|
||||
const iterator = readBytes(stream, chunkSize);
|
||||
const trackStream = (stream, chunkSize, onProgress, onFinish, encode) => {
|
||||
const iterator = readBytes(stream, chunkSize, encode);
|
||||
|
||||
let bytes = 0;
|
||||
|
||||
@@ -2681,6 +2679,12 @@ const fetchProgressDecorator = (total, fn) => {
|
||||
const isFetchSupported = typeof fetch !== 'undefined';
|
||||
const isReadableStreamSupported = isFetchSupported && typeof ReadableStream !== 'undefined';
|
||||
|
||||
// used only inside the fetch adapter
|
||||
const encodeText = isFetchSupported && (typeof TextEncoder !== 'undefined' ?
|
||||
((encoder) => (str) => encoder.encode(str))(new TextEncoder()) :
|
||||
async (str) => new Uint8Array(await new Response(str).arrayBuffer())
|
||||
);
|
||||
|
||||
const supportsRequestStream = isReadableStreamSupported && (() => {
|
||||
let duplexAccessed = false;
|
||||
|
||||
@@ -2741,7 +2745,7 @@ const getBodyLength = async (body) => {
|
||||
}
|
||||
|
||||
if(utils$1.isString(body)) {
|
||||
return (await new TextEncoder().encode(body)).byteLength;
|
||||
return (await encodeText(body)).byteLength;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2805,7 +2809,7 @@ const fetchAdapter = isFetchSupported && (async (config) => {
|
||||
data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, fetchProgressDecorator(
|
||||
requestContentLength,
|
||||
progressEventReducer(onUploadProgress)
|
||||
));
|
||||
), null, encodeText);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2840,7 +2844,7 @@ const fetchAdapter = isFetchSupported && (async (config) => {
|
||||
trackStream(response.body, DEFAULT_CHUNK_SIZE, onDownloadProgress && fetchProgressDecorator(
|
||||
responseContentLength,
|
||||
progressEventReducer(onDownloadProgress, true)
|
||||
), isStreamResponse && onFinish),
|
||||
), isStreamResponse && onFinish, encodeText),
|
||||
options
|
||||
);
|
||||
}
|
||||
@@ -3026,7 +3030,7 @@ function dispatchRequest(config) {
|
||||
});
|
||||
}
|
||||
|
||||
const VERSION$1 = "1.7.0";
|
||||
const VERSION$1 = "1.7.1";
|
||||
|
||||
const validators$1 = {};
|
||||
|
||||
|
||||
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
+15
-11
@@ -1,4 +1,4 @@
|
||||
// Axios v1.7.0 Copyright (c) 2024 Matt Zabriskie and contributors
|
||||
// Axios v1.7.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";
|
||||
const VERSION = "1.7.1";
|
||||
|
||||
function parseProtocol(url) {
|
||||
const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
|
||||
@@ -3702,16 +3702,14 @@ const streamChunk = function* (chunk, chunkSize) {
|
||||
}
|
||||
};
|
||||
|
||||
const encoder = new TextEncoder();
|
||||
|
||||
const readBytes = async function* (iterable, chunkSize) {
|
||||
const readBytes = async function* (iterable, chunkSize, encode) {
|
||||
for await (const chunk of iterable) {
|
||||
yield* streamChunk(ArrayBuffer.isView(chunk) ? chunk : (await encoder.encode(String(chunk))), chunkSize);
|
||||
yield* streamChunk(ArrayBuffer.isView(chunk) ? chunk : (await encode(String(chunk))), chunkSize);
|
||||
}
|
||||
};
|
||||
|
||||
const trackStream = (stream, chunkSize, onProgress, onFinish) => {
|
||||
const iterator = readBytes(stream, chunkSize);
|
||||
const trackStream = (stream, chunkSize, onProgress, onFinish, encode) => {
|
||||
const iterator = readBytes(stream, chunkSize, encode);
|
||||
|
||||
let bytes = 0;
|
||||
|
||||
@@ -3752,6 +3750,12 @@ const fetchProgressDecorator = (total, fn) => {
|
||||
const isFetchSupported = typeof fetch !== 'undefined';
|
||||
const isReadableStreamSupported = isFetchSupported && typeof ReadableStream !== 'undefined';
|
||||
|
||||
// used only inside the fetch adapter
|
||||
const encodeText = isFetchSupported && (typeof TextEncoder !== 'undefined' ?
|
||||
((encoder) => (str) => encoder.encode(str))(new TextEncoder()) :
|
||||
async (str) => new Uint8Array(await new Response(str).arrayBuffer())
|
||||
);
|
||||
|
||||
const supportsRequestStream = isReadableStreamSupported && (() => {
|
||||
let duplexAccessed = false;
|
||||
|
||||
@@ -3812,7 +3816,7 @@ const getBodyLength = async (body) => {
|
||||
}
|
||||
|
||||
if(utils$1.isString(body)) {
|
||||
return (await new TextEncoder().encode(body)).byteLength;
|
||||
return (await encodeText(body)).byteLength;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -3876,7 +3880,7 @@ const fetchAdapter = isFetchSupported && (async (config) => {
|
||||
data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, fetchProgressDecorator(
|
||||
requestContentLength,
|
||||
progressEventReducer(onUploadProgress)
|
||||
));
|
||||
), null, encodeText);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3911,7 +3915,7 @@ const fetchAdapter = isFetchSupported && (async (config) => {
|
||||
trackStream(response.body, DEFAULT_CHUNK_SIZE, onDownloadProgress && fetchProgressDecorator(
|
||||
responseContentLength,
|
||||
progressEventReducer(onDownloadProgress, true)
|
||||
), isStreamResponse && onFinish),
|
||||
), isStreamResponse && onFinish, encodeText),
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
@@ -1 +1 @@
|
||||
export const VERSION = "1.7.0";
|
||||
export const VERSION = "1.7.1";
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "axios",
|
||||
"version": "1.7.0",
|
||||
"version": "1.7.1",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "axios",
|
||||
"version": "1.7.0",
|
||||
"version": "1.7.1",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"follow-redirects": "^1.15.6",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "axios",
|
||||
"version": "1.7.0",
|
||||
"version": "1.7.1",
|
||||
"description": "Promise based HTTP client for the browser and node.js",
|
||||
"main": "index.js",
|
||||
"exports": {
|
||||
|
||||
Reference in New Issue
Block a user