axios 1.7.0-beta.1 → 1.7.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of axios might be problematic. Click here for more details.

package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ # [1.7.0-beta.2](https://github.com/axios/axios/compare/v1.7.0-beta.1...v1.7.0-beta.2) (2024-05-19)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **fetch:** capitalize HTTP method names; ([#6395](https://github.com/axios/axios/issues/6395)) ([ad3174a](https://github.com/axios/axios/commit/ad3174a3515c3c2573f4bcb94818d582826f3914))
9
+ * **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))
10
+ * **fetch:** fix headers getting from a stream response; ([#6401](https://github.com/axios/axios/issues/6401)) ([870e0a7](https://github.com/axios/axios/commit/870e0a76f60d0094774a6a63fa606eec52a381af))
11
+
12
+ ### Contributors to this release
13
+
14
+ - <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 )")
15
+
3
16
  # [1.7.0-beta.1](https://github.com/axios/axios/compare/v1.7.0-beta.0...v1.7.0-beta.1) (2024-05-07)
4
17
 
5
18
 
package/dist/axios.js CHANGED
@@ -1,4 +1,4 @@
1
- // Axios v1.7.0-beta.1 Copyright (c) 2024 Matt Zabriskie and contributors
1
+ // Axios v1.7.0-beta.2 Copyright (c) 2024 Matt Zabriskie and contributors
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
4
4
  typeof define === 'function' && define.amd ? define(factory) :
@@ -3266,39 +3266,45 @@
3266
3266
  return _regeneratorRuntime().wrap(function _callee$(_context) {
3267
3267
  while (1) switch (_context.prev = _context.next) {
3268
3268
  case 0:
3269
- if (!utils$1.isBlob(body)) {
3269
+ if (!(body == null)) {
3270
3270
  _context.next = 2;
3271
3271
  break;
3272
3272
  }
3273
- return _context.abrupt("return", body.size);
3273
+ return _context.abrupt("return", 0);
3274
3274
  case 2:
3275
+ if (!utils$1.isBlob(body)) {
3276
+ _context.next = 4;
3277
+ break;
3278
+ }
3279
+ return _context.abrupt("return", body.size);
3280
+ case 4:
3275
3281
  if (!utils$1.isSpecCompliantForm(body)) {
3276
- _context.next = 6;
3282
+ _context.next = 8;
3277
3283
  break;
3278
3284
  }
3279
- _context.next = 5;
3285
+ _context.next = 7;
3280
3286
  return new Request(body).arrayBuffer();
3281
- case 5:
3287
+ case 7:
3282
3288
  return _context.abrupt("return", _context.sent.byteLength);
3283
- case 6:
3289
+ case 8:
3284
3290
  if (!utils$1.isArrayBufferView(body)) {
3285
- _context.next = 8;
3291
+ _context.next = 10;
3286
3292
  break;
3287
3293
  }
3288
3294
  return _context.abrupt("return", body.byteLength);
3289
- case 8:
3295
+ case 10:
3290
3296
  if (utils$1.isURLSearchParams(body)) {
3291
3297
  body = body + '';
3292
3298
  }
3293
3299
  if (!utils$1.isString(body)) {
3294
- _context.next = 13;
3300
+ _context.next = 15;
3295
3301
  break;
3296
3302
  }
3297
- _context.next = 12;
3303
+ _context.next = 14;
3298
3304
  return new TextEncoder().encode(body);
3299
- case 12:
3305
+ case 14:
3300
3306
  return _context.abrupt("return", _context.sent.byteLength);
3301
- case 13:
3307
+ case 15:
3302
3308
  case "end":
3303
3309
  return _context.stop();
3304
3310
  }
@@ -3342,56 +3348,65 @@
3342
3348
  finished = true;
3343
3349
  };
3344
3350
  _context3.prev = 4;
3345
- if (!(onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head')) {
3346
- _context3.next = 12;
3351
+ _context3.t0 = onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head';
3352
+ if (!_context3.t0) {
3353
+ _context3.next = 11;
3347
3354
  break;
3348
3355
  }
3349
- _context3.next = 8;
3356
+ _context3.next = 9;
3350
3357
  return resolveBodyLength(headers, data);
3351
- case 8:
3352
- requestContentLength = _context3.sent;
3358
+ case 9:
3359
+ _context3.t1 = requestContentLength = _context3.sent;
3360
+ _context3.t0 = _context3.t1 !== 0;
3361
+ case 11:
3362
+ if (!_context3.t0) {
3363
+ _context3.next = 15;
3364
+ break;
3365
+ }
3353
3366
  _request = new Request(url, {
3354
- method: method,
3367
+ method: 'POST',
3355
3368
  body: data,
3356
3369
  duplex: "half"
3357
3370
  });
3358
3371
  if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
3359
3372
  headers.setContentType(contentTypeHeader);
3360
3373
  }
3361
- data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, fetchProgressDecorator(requestContentLength, progressEventReducer(onUploadProgress)));
3362
- case 12:
3374
+ if (_request.body) {
3375
+ data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, fetchProgressDecorator(requestContentLength, progressEventReducer(onUploadProgress)));
3376
+ }
3377
+ case 15:
3363
3378
  if (!utils$1.isString(withCredentials)) {
3364
3379
  withCredentials = withCredentials ? 'cors' : 'omit';
3365
3380
  }
3366
3381
  request = new Request(url, _objectSpread2(_objectSpread2({}, fetchOptions), {}, {
3367
3382
  signal: composedSignal,
3368
- method: method,
3383
+ method: method.toUpperCase(),
3369
3384
  headers: headers.normalize().toJSON(),
3370
3385
  body: data,
3371
3386
  duplex: "half",
3372
3387
  withCredentials: withCredentials
3373
3388
  }));
3374
- _context3.next = 16;
3389
+ _context3.next = 19;
3375
3390
  return fetch(request);
3376
- case 16:
3391
+ case 19:
3377
3392
  response = _context3.sent;
3378
3393
  isStreamResponse = responseType === 'stream' || responseType === 'response';
3379
3394
  if (supportsResponseStream && (onDownloadProgress || isStreamResponse)) {
3380
3395
  options = {};
3381
- Object.getOwnPropertyNames(response).forEach(function (prop) {
3396
+ ['status', 'statusText', 'headers'].forEach(function (prop) {
3382
3397
  options[prop] = response[prop];
3383
3398
  });
3384
3399
  responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
3385
3400
  response = new Response(trackStream(response.body, DEFAULT_CHUNK_SIZE, onDownloadProgress && fetchProgressDecorator(responseContentLength, progressEventReducer(onDownloadProgress, true)), isStreamResponse && onFinish), options);
3386
3401
  }
3387
3402
  responseType = responseType || 'text';
3388
- _context3.next = 22;
3403
+ _context3.next = 25;
3389
3404
  return resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
3390
- case 22:
3405
+ case 25:
3391
3406
  responseData = _context3.sent;
3392
3407
  !isStreamResponse && onFinish();
3393
3408
  stopTimeout && stopTimeout();
3394
- _context3.next = 27;
3409
+ _context3.next = 30;
3395
3410
  return new Promise(function (resolve, reject) {
3396
3411
  settle(resolve, reject, {
3397
3412
  data: responseData,
@@ -3402,26 +3417,26 @@
3402
3417
  request: request
3403
3418
  });
3404
3419
  });
3405
- case 27:
3406
- return _context3.abrupt("return", _context3.sent);
3407
3420
  case 30:
3408
- _context3.prev = 30;
3409
- _context3.t0 = _context3["catch"](4);
3421
+ return _context3.abrupt("return", _context3.sent);
3422
+ case 33:
3423
+ _context3.prev = 33;
3424
+ _context3.t2 = _context3["catch"](4);
3410
3425
  onFinish();
3411
- if (!(_context3.t0 && _context3.t0.name === 'TypeError' && /fetch/i.test(_context3.t0.message))) {
3412
- _context3.next = 35;
3426
+ if (!(_context3.t2 && _context3.t2.name === 'TypeError' && /fetch/i.test(_context3.t2.message))) {
3427
+ _context3.next = 38;
3413
3428
  break;
3414
3429
  }
3415
3430
  throw Object.assign(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request), {
3416
- cause: _context3.t0.cause || _context3.t0
3431
+ cause: _context3.t2.cause || _context3.t2
3417
3432
  });
3418
- case 35:
3419
- throw AxiosError.from(_context3.t0, _context3.t0 && _context3.t0.code, config, request);
3420
- case 36:
3433
+ case 38:
3434
+ throw AxiosError.from(_context3.t2, _context3.t2 && _context3.t2.code, config, request);
3435
+ case 39:
3421
3436
  case "end":
3422
3437
  return _context3.stop();
3423
3438
  }
3424
- }, _callee3, null, [[4, 30]]);
3439
+ }, _callee3, null, [[4, 33]]);
3425
3440
  }));
3426
3441
  return function (_x4) {
3427
3442
  return _ref3.apply(this, arguments);
@@ -3545,7 +3560,7 @@
3545
3560
  });
3546
3561
  }
3547
3562
 
3548
- var VERSION = "1.7.0-beta.1";
3563
+ var VERSION = "1.7.0-beta.2";
3549
3564
 
3550
3565
  var validators$1 = {};
3551
3566