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

chore(release): v1.7.0-beta.2 (#6403)

Co-authored-by: DigitalBrainJS <12586868+DigitalBrainJS@users.noreply.github.com>
This commit is contained in:
github-actions[bot]
2024-05-19 21:00:36 +03:00
committed by GitHub
parent d57f03a77f
commit b49aa8e3d8
17 changed files with 147 additions and 92 deletions
+13
View File
@@ -1,5 +1,18 @@
# Changelog # Changelog
# [1.7.0-beta.2](https://github.com/axios/axios/compare/v1.7.0-beta.1...v1.7.0-beta.2) (2024-05-19)
### Bug Fixes
* **fetch:** capitalize HTTP method names; ([#6395](https://github.com/axios/axios/issues/6395)) ([ad3174a](https://github.com/axios/axios/commit/ad3174a3515c3c2573f4bcb94818d582826f3914))
* **fetch:** fix & optimize progress capturing for cases when the request data has a nullish value or zero data length ([#6400](https://github.com/axios/axios/issues/6400)) ([95a3e8e](https://github.com/axios/axios/commit/95a3e8e346cfd6a5548e171f2341df3235d0e26b))
* **fetch:** fix headers getting from a stream response; ([#6401](https://github.com/axios/axios/issues/6401)) ([870e0a7](https://github.com/axios/axios/commit/870e0a76f60d0094774a6a63fa606eec52a381af))
### 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 "+99/-46 (#6405 #6404 #6401 #6400 #6395 )")
# [1.7.0-beta.1](https://github.com/axios/axios/compare/v1.7.0-beta.0...v1.7.0-beta.1) (2024-05-07) # [1.7.0-beta.1](https://github.com/axios/axios/compare/v1.7.0-beta.0...v1.7.0-beta.1) (2024-05-07)
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"name": "axios", "name": "axios",
"main": "./dist/axios.js", "main": "./dist/axios.js",
"version": "1.7.0-beta.1", "version": "1.7.0-beta.2",
"homepage": "https://axios-http.com", "homepage": "https://axios-http.com",
"authors": [ "authors": [
"Matt Zabriskie" "Matt Zabriskie"
+58 -43
View File
@@ -1,4 +1,4 @@
// Axios v1.7.0-beta.1 Copyright (c) 2024 Matt Zabriskie and contributors // Axios v1.7.0-beta.2 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) :
@@ -3266,39 +3266,45 @@
return _regeneratorRuntime().wrap(function _callee$(_context) { return _regeneratorRuntime().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) { while (1) switch (_context.prev = _context.next) {
case 0: case 0:
if (!utils$1.isBlob(body)) { if (!(body == null)) {
_context.next = 2; _context.next = 2;
break; break;
} }
return _context.abrupt("return", body.size); return _context.abrupt("return", 0);
case 2: case 2:
if (!utils$1.isSpecCompliantForm(body)) { if (!utils$1.isBlob(body)) {
_context.next = 6; _context.next = 4;
break; break;
} }
_context.next = 5; return _context.abrupt("return", body.size);
return new Request(body).arrayBuffer(); case 4:
case 5: if (!utils$1.isSpecCompliantForm(body)) {
return _context.abrupt("return", _context.sent.byteLength);
case 6:
if (!utils$1.isArrayBufferView(body)) {
_context.next = 8; _context.next = 8;
break; break;
} }
return _context.abrupt("return", body.byteLength); _context.next = 7;
return new Request(body).arrayBuffer();
case 7:
return _context.abrupt("return", _context.sent.byteLength);
case 8: case 8:
if (!utils$1.isArrayBufferView(body)) {
_context.next = 10;
break;
}
return _context.abrupt("return", body.byteLength);
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 = 13; _context.next = 15;
break; break;
} }
_context.next = 12; _context.next = 14;
return new TextEncoder().encode(body); return new TextEncoder().encode(body);
case 12: case 14:
return _context.abrupt("return", _context.sent.byteLength); return _context.abrupt("return", _context.sent.byteLength);
case 13: case 15:
case "end": case "end":
return _context.stop(); return _context.stop();
} }
@@ -3342,56 +3348,65 @@
finished = true; finished = true;
}; };
_context3.prev = 4; _context3.prev = 4;
if (!(onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head')) { _context3.t0 = onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head';
_context3.next = 12; if (!_context3.t0) {
_context3.next = 11;
break; break;
} }
_context3.next = 8; _context3.next = 9;
return resolveBodyLength(headers, data); return resolveBodyLength(headers, data);
case 8: case 9:
requestContentLength = _context3.sent; _context3.t1 = requestContentLength = _context3.sent;
_context3.t0 = _context3.t1 !== 0;
case 11:
if (!_context3.t0) {
_context3.next = 15;
break;
}
_request = new Request(url, { _request = new Request(url, {
method: method, method: 'POST',
body: data, body: data,
duplex: "half" duplex: "half"
}); });
if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) { if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
headers.setContentType(contentTypeHeader); headers.setContentType(contentTypeHeader);
} }
data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, fetchProgressDecorator(requestContentLength, progressEventReducer(onUploadProgress))); if (_request.body) {
case 12: data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, fetchProgressDecorator(requestContentLength, progressEventReducer(onUploadProgress)));
}
case 15:
if (!utils$1.isString(withCredentials)) { if (!utils$1.isString(withCredentials)) {
withCredentials = withCredentials ? 'cors' : 'omit'; withCredentials = withCredentials ? 'cors' : 'omit';
} }
request = new Request(url, _objectSpread2(_objectSpread2({}, fetchOptions), {}, { request = new Request(url, _objectSpread2(_objectSpread2({}, fetchOptions), {}, {
signal: composedSignal, signal: composedSignal,
method: method, method: method.toUpperCase(),
headers: headers.normalize().toJSON(), headers: headers.normalize().toJSON(),
body: data, body: data,
duplex: "half", duplex: "half",
withCredentials: withCredentials withCredentials: withCredentials
})); }));
_context3.next = 16; _context3.next = 19;
return fetch(request); return fetch(request);
case 16: case 19:
response = _context3.sent; response = _context3.sent;
isStreamResponse = responseType === 'stream' || responseType === 'response'; isStreamResponse = responseType === 'stream' || responseType === 'response';
if (supportsResponseStream && (onDownloadProgress || isStreamResponse)) { if (supportsResponseStream && (onDownloadProgress || isStreamResponse)) {
options = {}; options = {};
Object.getOwnPropertyNames(response).forEach(function (prop) { ['status', 'statusText', 'headers'].forEach(function (prop) {
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), options);
} }
responseType = responseType || 'text'; responseType = responseType || 'text';
_context3.next = 22; _context3.next = 25;
return resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config); return resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
case 22: case 25:
responseData = _context3.sent; responseData = _context3.sent;
!isStreamResponse && onFinish(); !isStreamResponse && onFinish();
stopTimeout && stopTimeout(); stopTimeout && stopTimeout();
_context3.next = 27; _context3.next = 30;
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
settle(resolve, reject, { settle(resolve, reject, {
data: responseData, data: responseData,
@@ -3402,26 +3417,26 @@
request: request request: request
}); });
}); });
case 27:
return _context3.abrupt("return", _context3.sent);
case 30: case 30:
_context3.prev = 30; return _context3.abrupt("return", _context3.sent);
_context3.t0 = _context3["catch"](4); case 33:
_context3.prev = 33;
_context3.t2 = _context3["catch"](4);
onFinish(); onFinish();
if (!(_context3.t0 && _context3.t0.name === 'TypeError' && /fetch/i.test(_context3.t0.message))) { if (!(_context3.t2 && _context3.t2.name === 'TypeError' && /fetch/i.test(_context3.t2.message))) {
_context3.next = 35; _context3.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.t0.cause || _context3.t0 cause: _context3.t2.cause || _context3.t2
}); });
case 35: case 38:
throw AxiosError.from(_context3.t0, _context3.t0 && _context3.t0.code, config, request); throw AxiosError.from(_context3.t2, _context3.t2 && _context3.t2.code, config, request);
case 36: case 39:
case "end": case "end":
return _context3.stop(); return _context3.stop();
} }
}, _callee3, null, [[4, 30]]); }, _callee3, null, [[4, 33]]);
})); }));
return function (_x4) { return function (_x4) {
return _ref3.apply(this, arguments); return _ref3.apply(this, arguments);
@@ -3545,7 +3560,7 @@
}); });
} }
var VERSION = "1.7.0-beta.1"; var VERSION = "1.7.0-beta.2";
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
+21 -12
View File
@@ -1,4 +1,4 @@
// Axios v1.7.0-beta.1 Copyright (c) 2024 Matt Zabriskie and contributors // Axios v1.7.0-beta.2 Copyright (c) 2024 Matt Zabriskie and contributors
'use strict'; 'use strict';
function bind(fn, thisArg) { function bind(fn, thisArg) {
@@ -2722,6 +2722,10 @@ isFetchSupported && (((res) => {
})(new Response)); })(new Response));
const getBodyLength = async (body) => { const getBodyLength = async (body) => {
if (body == null) {
return 0;
}
if(utils$1.isBlob(body)) { if(utils$1.isBlob(body)) {
return body.size; return body.size;
} }
@@ -2780,12 +2784,15 @@ var fetchAdapter = isFetchSupported && (async (config) => {
finished = true; finished = true;
}; };
try { let requestContentLength;
if (onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head') {
let requestContentLength = await resolveBodyLength(headers, data);
try {
if (
onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head' &&
(requestContentLength = await resolveBodyLength(headers, data)) !== 0
) {
let _request = new Request(url, { let _request = new Request(url, {
method, method: 'POST',
body: data, body: data,
duplex: "half" duplex: "half"
}); });
@@ -2796,10 +2803,12 @@ var fetchAdapter = isFetchSupported && (async (config) => {
headers.setContentType(contentTypeHeader); headers.setContentType(contentTypeHeader);
} }
data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, fetchProgressDecorator( if (_request.body) {
requestContentLength, data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, fetchProgressDecorator(
progressEventReducer(onUploadProgress) requestContentLength,
)); progressEventReducer(onUploadProgress)
));
}
} }
if (!utils$1.isString(withCredentials)) { if (!utils$1.isString(withCredentials)) {
@@ -2809,7 +2818,7 @@ var fetchAdapter = isFetchSupported && (async (config) => {
request = new Request(url, { request = new Request(url, {
...fetchOptions, ...fetchOptions,
signal: composedSignal, signal: composedSignal,
method, method: method.toUpperCase(),
headers: headers.normalize().toJSON(), headers: headers.normalize().toJSON(),
body: data, body: data,
duplex: "half", duplex: "half",
@@ -2823,7 +2832,7 @@ var fetchAdapter = isFetchSupported && (async (config) => {
if (supportsResponseStream && (onDownloadProgress || isStreamResponse)) { if (supportsResponseStream && (onDownloadProgress || isStreamResponse)) {
const options = {}; const options = {};
Object.getOwnPropertyNames(response).forEach(prop => { ['status', 'statusText', 'headers'].forEach(prop => {
options[prop] = response[prop]; options[prop] = response[prop];
}); });
@@ -3019,7 +3028,7 @@ function dispatchRequest(config) {
}); });
} }
const VERSION = "1.7.0-beta.1"; const VERSION = "1.7.0-beta.2";
const validators$1 = {}; const validators$1 = {};
+1 -1
View File
File diff suppressed because one or more lines are too long
+21 -12
View File
@@ -1,4 +1,4 @@
// Axios v1.7.0-beta.1 Copyright (c) 2024 Matt Zabriskie and contributors // Axios v1.7.0-beta.2 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);
@@ -2720,6 +2720,10 @@ isFetchSupported && (((res) => {
})(new Response)); })(new Response));
const getBodyLength = async (body) => { const getBodyLength = async (body) => {
if (body == null) {
return 0;
}
if(utils$1.isBlob(body)) { if(utils$1.isBlob(body)) {
return body.size; return body.size;
} }
@@ -2778,12 +2782,15 @@ const fetchAdapter = isFetchSupported && (async (config) => {
finished = true; finished = true;
}; };
try { let requestContentLength;
if (onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head') {
let requestContentLength = await resolveBodyLength(headers, data);
try {
if (
onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head' &&
(requestContentLength = await resolveBodyLength(headers, data)) !== 0
) {
let _request = new Request(url, { let _request = new Request(url, {
method, method: 'POST',
body: data, body: data,
duplex: "half" duplex: "half"
}); });
@@ -2794,10 +2801,12 @@ const fetchAdapter = isFetchSupported && (async (config) => {
headers.setContentType(contentTypeHeader); headers.setContentType(contentTypeHeader);
} }
data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, fetchProgressDecorator( if (_request.body) {
requestContentLength, data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, fetchProgressDecorator(
progressEventReducer(onUploadProgress) requestContentLength,
)); progressEventReducer(onUploadProgress)
));
}
} }
if (!utils$1.isString(withCredentials)) { if (!utils$1.isString(withCredentials)) {
@@ -2807,7 +2816,7 @@ const fetchAdapter = isFetchSupported && (async (config) => {
request = new Request(url, { request = new Request(url, {
...fetchOptions, ...fetchOptions,
signal: composedSignal, signal: composedSignal,
method, method: method.toUpperCase(),
headers: headers.normalize().toJSON(), headers: headers.normalize().toJSON(),
body: data, body: data,
duplex: "half", duplex: "half",
@@ -2821,7 +2830,7 @@ const fetchAdapter = isFetchSupported && (async (config) => {
if (supportsResponseStream && (onDownloadProgress || isStreamResponse)) { if (supportsResponseStream && (onDownloadProgress || isStreamResponse)) {
const options = {}; const options = {};
Object.getOwnPropertyNames(response).forEach(prop => { ['status', 'statusText', 'headers'].forEach(prop => {
options[prop] = response[prop]; options[prop] = response[prop];
}); });
@@ -3017,7 +3026,7 @@ function dispatchRequest(config) {
}); });
} }
const VERSION$1 = "1.7.0-beta.1"; const VERSION$1 = "1.7.0-beta.2";
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
+21 -12
View File
@@ -1,4 +1,4 @@
// Axios v1.7.0-beta.1 Copyright (c) 2024 Matt Zabriskie and contributors // Axios v1.7.0-beta.2 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-beta.1"; const VERSION = "1.7.0-beta.2";
function parseProtocol(url) { function parseProtocol(url) {
const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url); const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
@@ -3791,6 +3791,10 @@ isFetchSupported && (((res) => {
})(new Response)); })(new Response));
const getBodyLength = async (body) => { const getBodyLength = async (body) => {
if (body == null) {
return 0;
}
if(utils$1.isBlob(body)) { if(utils$1.isBlob(body)) {
return body.size; return body.size;
} }
@@ -3849,12 +3853,15 @@ const fetchAdapter = isFetchSupported && (async (config) => {
finished = true; finished = true;
}; };
try { let requestContentLength;
if (onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head') {
let requestContentLength = await resolveBodyLength(headers, data);
try {
if (
onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head' &&
(requestContentLength = await resolveBodyLength(headers, data)) !== 0
) {
let _request = new Request(url, { let _request = new Request(url, {
method, method: 'POST',
body: data, body: data,
duplex: "half" duplex: "half"
}); });
@@ -3865,10 +3872,12 @@ const fetchAdapter = isFetchSupported && (async (config) => {
headers.setContentType(contentTypeHeader); headers.setContentType(contentTypeHeader);
} }
data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, fetchProgressDecorator( if (_request.body) {
requestContentLength, data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, fetchProgressDecorator(
progressEventReducer(onUploadProgress) requestContentLength,
)); progressEventReducer(onUploadProgress)
));
}
} }
if (!utils$1.isString(withCredentials)) { if (!utils$1.isString(withCredentials)) {
@@ -3878,7 +3887,7 @@ const fetchAdapter = isFetchSupported && (async (config) => {
request = new Request(url, { request = new Request(url, {
...fetchOptions, ...fetchOptions,
signal: composedSignal, signal: composedSignal,
method, method: method.toUpperCase(),
headers: headers.normalize().toJSON(), headers: headers.normalize().toJSON(),
body: data, body: data,
duplex: "half", duplex: "half",
@@ -3892,7 +3901,7 @@ const fetchAdapter = isFetchSupported && (async (config) => {
if (supportsResponseStream && (onDownloadProgress || isStreamResponse)) { if (supportsResponseStream && (onDownloadProgress || isStreamResponse)) {
const options = {}; const options = {};
Object.getOwnPropertyNames(response).forEach(prop => { ['status', 'statusText', 'headers'].forEach(prop => {
options[prop] = response[prop]; options[prop] = response[prop];
}); });
+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-beta.1"; export const VERSION = "1.7.0-beta.2";
+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "axios", "name": "axios",
"version": "1.7.0-beta.1", "version": "1.7.0-beta.2",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "axios", "name": "axios",
"version": "1.7.0-beta.1", "version": "1.7.0-beta.2",
"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-beta.1", "version": "1.7.0-beta.2",
"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": {