2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-23 20:40:40 +03:00

chore(release): v1.7.1 (#6411)

Co-authored-by: DigitalBrainJS <12586868+DigitalBrainJS@users.noreply.github.com>
This commit is contained in:
github-actions[bot]
2024-05-20 16:31:57 +03:00
committed by GitHub
parent 733f15fe5b
commit 67d1373131
17 changed files with 172 additions and 123 deletions
+11
View File
@@ -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&#x3D;4&amp;s&#x3D;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) # [1.7.0](https://github.com/axios/axios/compare/v1.7.0-beta.2...v1.7.0) (2024-05-19)
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"name": "axios", "name": "axios",
"main": "./dist/axios.js", "main": "./dist/axios.js",
"version": "1.7.0", "version": "1.7.1",
"homepage": "https://axios-http.com", "homepage": "https://axios-http.com",
"authors": [ "authors": [
"Matt Zabriskie" "Matt Zabriskie"
+100 -74
View File
@@ -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) { (function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) : typeof define === 'function' && define.amd ? define(factory) :
@@ -3085,9 +3085,8 @@
} }
}, streamChunk); }, streamChunk);
}); });
var encoder = new TextEncoder();
var readBytes = /*#__PURE__*/function () { 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; var _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, chunk;
return _regeneratorRuntime().wrap(function _callee$(_context2) { return _regeneratorRuntime().wrap(function _callee$(_context2) {
while (1) switch (_context2.prev = _context2.next) { while (1) switch (_context2.prev = _context2.next) {
@@ -3117,7 +3116,7 @@
break; break;
case 15: case 15:
_context2.next = 17; _context2.next = 17;
return _awaitAsyncGenerator(encoder.encode(String(chunk))); return _awaitAsyncGenerator(encode(String(chunk)));
case 17: case 17:
_context2.t3 = _context2.sent; _context2.t3 = _context2.sent;
case 18: case 18:
@@ -3165,12 +3164,12 @@
} }
}, _callee, null, [[2, 29, 33, 43], [34,, 38, 42]]); }, _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); return _ref.apply(this, arguments);
}; };
}(); }();
var trackStream = function trackStream(stream, chunkSize, onProgress, onFinish) { var trackStream = function trackStream(stream, chunkSize, onProgress, onFinish, encode) {
var iterator = readBytes(stream, chunkSize); var iterator = readBytes(stream, chunkSize, encode);
var bytes = 0; var bytes = 0;
return new ReadableStream({ return new ReadableStream({
type: 'bytes', type: 'bytes',
@@ -3227,6 +3226,33 @@
}; };
var isFetchSupported = typeof fetch !== 'undefined'; var isFetchSupported = typeof fetch !== 'undefined';
var isReadableStreamSupported = isFetchSupported && typeof ReadableStream !== '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 supportsRequestStream = isReadableStreamSupported && function () {
var duplexAccessed = false; var duplexAccessed = false;
var hasContentType = new Request(platform.origin, { var hasContentType = new Request(platform.origin, {
@@ -3262,105 +3288,105 @@
}); });
}(new Response()); }(new Response());
var getBodyLength = /*#__PURE__*/function () { var getBodyLength = /*#__PURE__*/function () {
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(body) { var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(body) {
return _regeneratorRuntime().wrap(function _callee$(_context) { return _regeneratorRuntime().wrap(function _callee2$(_context2) {
while (1) switch (_context.prev = _context.next) { while (1) switch (_context2.prev = _context2.next) {
case 0: case 0:
if (!(body == null)) { if (!(body == null)) {
_context.next = 2; _context2.next = 2;
break; break;
} }
return _context.abrupt("return", 0); return _context2.abrupt("return", 0);
case 2: case 2:
if (!utils$1.isBlob(body)) { if (!utils$1.isBlob(body)) {
_context.next = 4; _context2.next = 4;
break; break;
} }
return _context.abrupt("return", body.size); return _context2.abrupt("return", body.size);
case 4: case 4:
if (!utils$1.isSpecCompliantForm(body)) { if (!utils$1.isSpecCompliantForm(body)) {
_context.next = 8; _context2.next = 8;
break; break;
} }
_context.next = 7; _context2.next = 7;
return new Request(body).arrayBuffer(); return new Request(body).arrayBuffer();
case 7: case 7:
return _context.abrupt("return", _context.sent.byteLength); return _context2.abrupt("return", _context2.sent.byteLength);
case 8: case 8:
if (!utils$1.isArrayBufferView(body)) { if (!utils$1.isArrayBufferView(body)) {
_context.next = 10; _context2.next = 10;
break; break;
} }
return _context.abrupt("return", body.byteLength); return _context2.abrupt("return", body.byteLength);
case 10: case 10:
if (utils$1.isURLSearchParams(body)) { if (utils$1.isURLSearchParams(body)) {
body = body + ''; body = body + '';
} }
if (!utils$1.isString(body)) { if (!utils$1.isString(body)) {
_context.next = 15; _context2.next = 15;
break; break;
} }
_context.next = 14; _context2.next = 14;
return new TextEncoder().encode(body); return encodeText(body);
case 14: case 14:
return _context.abrupt("return", _context.sent.byteLength); return _context2.abrupt("return", _context2.sent.byteLength);
case 15: 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": case "end":
return _context2.stop(); return _context2.stop();
} }
}, _callee2); }, _callee2);
})); }));
return function resolveBodyLength(_x2, _x3) { return function getBodyLength(_x2) {
return _ref2.apply(this, arguments); return _ref2.apply(this, arguments);
}; };
}(); }();
var fetchAdapter = isFetchSupported && ( /*#__PURE__*/function () { var resolveBodyLength = /*#__PURE__*/function () {
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(config) { var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(headers, body) {
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 length;
return _regeneratorRuntime().wrap(function _callee3$(_context3) { return _regeneratorRuntime().wrap(function _callee3$(_context3) {
while (1) switch (_context3.prev = _context3.next) { 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: 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; _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'; 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() { onFinish = function onFinish() {
!finished && setTimeout(function () { !finished && setTimeout(function () {
composedSignal && composedSignal.unsubscribe(); composedSignal && composedSignal.unsubscribe();
}); });
finished = true; finished = true;
}; };
_context3.prev = 4; _context4.prev = 4;
_context3.t0 = onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head'; _context4.t0 = onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head';
if (!_context3.t0) { if (!_context4.t0) {
_context3.next = 11; _context4.next = 11;
break; break;
} }
_context3.next = 9; _context4.next = 9;
return resolveBodyLength(headers, data); return resolveBodyLength(headers, data);
case 9: case 9:
_context3.t1 = requestContentLength = _context3.sent; _context4.t1 = requestContentLength = _context4.sent;
_context3.t0 = _context3.t1 !== 0; _context4.t0 = _context4.t1 !== 0;
case 11: case 11:
if (!_context3.t0) { if (!_context4.t0) {
_context3.next = 15; _context4.next = 15;
break; break;
} }
_request = new Request(url, { _request = new Request(url, {
@@ -3372,7 +3398,7 @@
headers.setContentType(contentTypeHeader); headers.setContentType(contentTypeHeader);
} }
if (_request.body) { 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: case 15:
if (!utils$1.isString(withCredentials)) { if (!utils$1.isString(withCredentials)) {
@@ -3386,10 +3412,10 @@
duplex: "half", duplex: "half",
withCredentials: withCredentials withCredentials: withCredentials
})); }));
_context3.next = 19; _context4.next = 19;
return fetch(request); return fetch(request);
case 19: case 19:
response = _context3.sent; response = _context4.sent;
isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response'); isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
if (supportsResponseStream && (onDownloadProgress || isStreamResponse)) { if (supportsResponseStream && (onDownloadProgress || isStreamResponse)) {
options = {}; options = {};
@@ -3397,16 +3423,16 @@
options[prop] = response[prop]; options[prop] = response[prop];
}); });
responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length')); 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'; responseType = responseType || 'text';
_context3.next = 25; _context4.next = 25;
return resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config); return resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
case 25: case 25:
responseData = _context3.sent; responseData = _context4.sent;
!isStreamResponse && onFinish(); !isStreamResponse && onFinish();
stopTimeout && stopTimeout(); stopTimeout && stopTimeout();
_context3.next = 30; _context4.next = 30;
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
settle(resolve, reject, { settle(resolve, reject, {
data: responseData, data: responseData,
@@ -3418,28 +3444,28 @@
}); });
}); });
case 30: case 30:
return _context3.abrupt("return", _context3.sent); return _context4.abrupt("return", _context4.sent);
case 33: case 33:
_context3.prev = 33; _context4.prev = 33;
_context3.t2 = _context3["catch"](4); _context4.t2 = _context4["catch"](4);
onFinish(); onFinish();
if (!(_context3.t2 && _context3.t2.name === 'TypeError' && /fetch/i.test(_context3.t2.message))) { if (!(_context4.t2 && _context4.t2.name === 'TypeError' && /fetch/i.test(_context4.t2.message))) {
_context3.next = 38; _context4.next = 38;
break; break;
} }
throw Object.assign(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request), { 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: 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 39:
case "end": case "end":
return _context3.stop(); return _context4.stop();
} }
}, _callee3, null, [[4, 33]]); }, _callee4, null, [[4, 33]]);
})); }));
return function (_x4) { return function (_x5) {
return _ref3.apply(this, arguments); return _ref4.apply(this, arguments);
}; };
}()); }());
@@ -3560,7 +3586,7 @@
}); });
} }
var VERSION = "1.7.0"; var VERSION = "1.7.1";
var validators$1 = {}; var validators$1 = {};
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+15 -11
View File
@@ -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'; 'use strict';
function bind(fn, thisArg) { function bind(fn, thisArg) {
@@ -2633,16 +2633,14 @@ const streamChunk = function* (chunk, chunkSize) {
} }
}; };
const encoder = new TextEncoder(); const readBytes = async function* (iterable, chunkSize, encode) {
const readBytes = async function* (iterable, chunkSize) {
for await (const chunk of iterable) { 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 trackStream = (stream, chunkSize, onProgress, onFinish, encode) => {
const iterator = readBytes(stream, chunkSize); const iterator = readBytes(stream, chunkSize, encode);
let bytes = 0; let bytes = 0;
@@ -2683,6 +2681,12 @@ const fetchProgressDecorator = (total, fn) => {
const isFetchSupported = typeof fetch !== 'undefined'; const isFetchSupported = typeof fetch !== 'undefined';
const isReadableStreamSupported = isFetchSupported && typeof ReadableStream !== '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 && (() => { const supportsRequestStream = isReadableStreamSupported && (() => {
let duplexAccessed = false; let duplexAccessed = false;
@@ -2743,7 +2747,7 @@ const getBodyLength = async (body) => {
} }
if(utils$1.isString(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( data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, fetchProgressDecorator(
requestContentLength, requestContentLength,
progressEventReducer(onUploadProgress) progressEventReducer(onUploadProgress)
)); ), null, encodeText);
} }
} }
@@ -2842,7 +2846,7 @@ var fetchAdapter = isFetchSupported && (async (config) => {
trackStream(response.body, DEFAULT_CHUNK_SIZE, onDownloadProgress && fetchProgressDecorator( trackStream(response.body, DEFAULT_CHUNK_SIZE, onDownloadProgress && fetchProgressDecorator(
responseContentLength, responseContentLength,
progressEventReducer(onDownloadProgress, true) progressEventReducer(onDownloadProgress, true)
), isStreamResponse && onFinish), ), isStreamResponse && onFinish, encodeText),
options options
); );
} }
@@ -3028,7 +3032,7 @@ function dispatchRequest(config) {
}); });
} }
const VERSION = "1.7.0"; const VERSION = "1.7.1";
const validators$1 = {}; const validators$1 = {};
+1 -1
View File
File diff suppressed because one or more lines are too long
+15 -11
View File
@@ -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) { function bind(fn, thisArg) {
return function wrap() { return function wrap() {
return fn.apply(thisArg, arguments); return fn.apply(thisArg, arguments);
@@ -2631,16 +2631,14 @@ const streamChunk = function* (chunk, chunkSize) {
} }
}; };
const encoder = new TextEncoder(); const readBytes = async function* (iterable, chunkSize, encode) {
const readBytes = async function* (iterable, chunkSize) {
for await (const chunk of iterable) { 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 trackStream = (stream, chunkSize, onProgress, onFinish, encode) => {
const iterator = readBytes(stream, chunkSize); const iterator = readBytes(stream, chunkSize, encode);
let bytes = 0; let bytes = 0;
@@ -2681,6 +2679,12 @@ const fetchProgressDecorator = (total, fn) => {
const isFetchSupported = typeof fetch !== 'undefined'; const isFetchSupported = typeof fetch !== 'undefined';
const isReadableStreamSupported = isFetchSupported && typeof ReadableStream !== '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 && (() => { const supportsRequestStream = isReadableStreamSupported && (() => {
let duplexAccessed = false; let duplexAccessed = false;
@@ -2741,7 +2745,7 @@ const getBodyLength = async (body) => {
} }
if(utils$1.isString(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( data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, fetchProgressDecorator(
requestContentLength, requestContentLength,
progressEventReducer(onUploadProgress) progressEventReducer(onUploadProgress)
)); ), null, encodeText);
} }
} }
@@ -2840,7 +2844,7 @@ const fetchAdapter = isFetchSupported && (async (config) => {
trackStream(response.body, DEFAULT_CHUNK_SIZE, onDownloadProgress && fetchProgressDecorator( trackStream(response.body, DEFAULT_CHUNK_SIZE, onDownloadProgress && fetchProgressDecorator(
responseContentLength, responseContentLength,
progressEventReducer(onDownloadProgress, true) progressEventReducer(onDownloadProgress, true)
), isStreamResponse && onFinish), ), isStreamResponse && onFinish, encodeText),
options options
); );
} }
@@ -3026,7 +3030,7 @@ function dispatchRequest(config) {
}); });
} }
const VERSION$1 = "1.7.0"; const VERSION$1 = "1.7.1";
const validators$1 = {}; const validators$1 = {};
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+15 -11
View File
@@ -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'; 'use strict';
const FormData$1 = require('form-data'); const FormData$1 = require('form-data');
@@ -2035,7 +2035,7 @@ function buildFullPath(baseURL, requestedURL) {
return requestedURL; return requestedURL;
} }
const VERSION = "1.7.0"; const VERSION = "1.7.1";
function parseProtocol(url) { function parseProtocol(url) {
const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(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, encode) {
const readBytes = async function* (iterable, chunkSize) {
for await (const chunk of iterable) { 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 trackStream = (stream, chunkSize, onProgress, onFinish, encode) => {
const iterator = readBytes(stream, chunkSize); const iterator = readBytes(stream, chunkSize, encode);
let bytes = 0; let bytes = 0;
@@ -3752,6 +3750,12 @@ const fetchProgressDecorator = (total, fn) => {
const isFetchSupported = typeof fetch !== 'undefined'; const isFetchSupported = typeof fetch !== 'undefined';
const isReadableStreamSupported = isFetchSupported && typeof ReadableStream !== '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 && (() => { const supportsRequestStream = isReadableStreamSupported && (() => {
let duplexAccessed = false; let duplexAccessed = false;
@@ -3812,7 +3816,7 @@ const getBodyLength = async (body) => {
} }
if(utils$1.isString(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( data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, fetchProgressDecorator(
requestContentLength, requestContentLength,
progressEventReducer(onUploadProgress) progressEventReducer(onUploadProgress)
)); ), null, encodeText);
} }
} }
@@ -3911,7 +3915,7 @@ const fetchAdapter = isFetchSupported && (async (config) => {
trackStream(response.body, DEFAULT_CHUNK_SIZE, onDownloadProgress && fetchProgressDecorator( trackStream(response.body, DEFAULT_CHUNK_SIZE, onDownloadProgress && fetchProgressDecorator(
responseContentLength, responseContentLength,
progressEventReducer(onDownloadProgress, true) progressEventReducer(onDownloadProgress, true)
), isStreamResponse && onFinish), ), isStreamResponse && onFinish, encodeText),
options options
); );
} }
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1 +1 @@
export const VERSION = "1.7.0"; export const VERSION = "1.7.1";
+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "axios", "name": "axios",
"version": "1.7.0", "version": "1.7.1",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "axios", "name": "axios",
"version": "1.7.0", "version": "1.7.1",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"follow-redirects": "^1.15.6", "follow-redirects": "^1.15.6",
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "axios", "name": "axios",
"version": "1.7.0", "version": "1.7.1",
"description": "Promise based HTTP client for the browser and node.js", "description": "Promise based HTTP client for the browser and node.js",
"main": "index.js", "main": "index.js",
"exports": { "exports": {