got 14.4.8 → 14.4.9
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.
|
@@ -449,10 +449,22 @@ export default class Request extends Duplex {
|
|
|
449
449
|
const { options } = this;
|
|
450
450
|
const { url } = options;
|
|
451
451
|
this._nativeResponse = response;
|
|
452
|
-
|
|
452
|
+
const statusCode = response.statusCode;
|
|
453
|
+
const { method } = options;
|
|
454
|
+
// Skip decompression for responses that must not have bodies per RFC 9110:
|
|
455
|
+
// - HEAD responses (any status code)
|
|
456
|
+
// - 1xx (Informational): 100, 101, 102, 103, etc.
|
|
457
|
+
// - 204 (No Content)
|
|
458
|
+
// - 205 (Reset Content)
|
|
459
|
+
// - 304 (Not Modified)
|
|
460
|
+
const hasNoBody = method === 'HEAD'
|
|
461
|
+
|| (statusCode >= 100 && statusCode < 200)
|
|
462
|
+
|| statusCode === 204
|
|
463
|
+
|| statusCode === 205
|
|
464
|
+
|| statusCode === 304;
|
|
465
|
+
if (options.decompress && !hasNoBody) {
|
|
453
466
|
response = decompressResponse(response);
|
|
454
467
|
}
|
|
455
|
-
const statusCode = response.statusCode;
|
|
456
468
|
const typedResponse = response;
|
|
457
469
|
typedResponse.statusMessage = typedResponse.statusMessage ?? http.STATUS_CODES[statusCode];
|
|
458
470
|
typedResponse.url = options.url.toString();
|
|
@@ -337,6 +337,8 @@ Delays between retries counts with function `1000 * Math.pow(2, retry) + Math.ra
|
|
|
337
337
|
The `calculateDelay` property is a `function` that receives an object with `attemptCount`, `retryOptions`, `error` and `computedValue` properties for current retry count, the retry options, error and default computed value.
|
|
338
338
|
The function must return a delay in milliseconds (or a Promise resolving with it) (`0` return value cancels retry).
|
|
339
339
|
|
|
340
|
+
__Note:__ When you provide `calculateDelay`, you take full control of retry decisions. The `limit` option is not automatically enforced - you must check `attemptCount` yourself or return `0` when `computedValue` is `0` to respect the default retry logic.
|
|
341
|
+
|
|
340
342
|
By default, it retries *only* on the specified methods, status codes, and on these network errors:
|
|
341
343
|
- `ETIMEDOUT`: One of the [timeout](#timeout) limits were reached.
|
|
342
344
|
- `ECONNRESET`: Connection was forcibly closed by a peer.
|
|
@@ -1005,6 +1007,8 @@ export default class Options {
|
|
|
1005
1007
|
The `calculateDelay` property is a `function` that receives an object with `attemptCount`, `retryOptions`, `error` and `computedValue` properties for current retry count, the retry options, error and default computed value.
|
|
1006
1008
|
The function must return a delay in milliseconds (or a Promise resolving with it) (`0` return value cancels retry).
|
|
1007
1009
|
|
|
1010
|
+
__Note:__ When you provide `calculateDelay`, you take full control of retry decisions. The `limit` option is not automatically enforced - you must check `attemptCount` yourself or return `0` when `computedValue` is `0` to respect the default retry logic.
|
|
1011
|
+
|
|
1008
1012
|
By default, it retries *only* on the specified methods, status codes, and on these network errors:
|
|
1009
1013
|
|
|
1010
1014
|
- `ETIMEDOUT`: One of the [timeout](#timeout) limits were reached.
|
|
@@ -1261,6 +1261,8 @@ export default class Options {
|
|
|
1261
1261
|
The `calculateDelay` property is a `function` that receives an object with `attemptCount`, `retryOptions`, `error` and `computedValue` properties for current retry count, the retry options, error and default computed value.
|
|
1262
1262
|
The function must return a delay in milliseconds (or a Promise resolving with it) (`0` return value cancels retry).
|
|
1263
1263
|
|
|
1264
|
+
__Note:__ When you provide `calculateDelay`, you take full control of retry decisions. The `limit` option is not automatically enforced - you must check `attemptCount` yourself or return `0` when `computedValue` is `0` to respect the default retry logic.
|
|
1265
|
+
|
|
1264
1266
|
By default, it retries *only* on the specified methods, status codes, and on these network errors:
|
|
1265
1267
|
|
|
1266
1268
|
- `ETIMEDOUT`: One of the [timeout](#timeout) limits were reached.
|