got 14.4.7 → 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.
|
|
@@ -1173,7 +1177,7 @@ export default class Options {
|
|
|
1173
1177
|
passphrase: string | undefined;
|
|
1174
1178
|
pfx: PfxType;
|
|
1175
1179
|
rejectUnauthorized: boolean | undefined;
|
|
1176
|
-
checkServerIdentity: typeof checkServerIdentity
|
|
1180
|
+
checkServerIdentity: CheckServerIdentityFunction | typeof checkServerIdentity;
|
|
1177
1181
|
ciphers: string | undefined;
|
|
1178
1182
|
honorCipherOrder: boolean | undefined;
|
|
1179
1183
|
minVersion: import("tls").SecureVersion | undefined;
|
|
@@ -359,7 +359,10 @@ export default class Options {
|
|
|
359
359
|
return;
|
|
360
360
|
}
|
|
361
361
|
if (options instanceof Options) {
|
|
362
|
-
|
|
362
|
+
// Create a copy of the _init array to avoid infinite loop
|
|
363
|
+
// when merging an Options instance with itself
|
|
364
|
+
const initArray = [...options._init];
|
|
365
|
+
for (const init of initArray) {
|
|
363
366
|
this.merge(init);
|
|
364
367
|
}
|
|
365
368
|
return;
|
|
@@ -1258,6 +1261,8 @@ export default class Options {
|
|
|
1258
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.
|
|
1259
1262
|
The function must return a delay in milliseconds (or a Promise resolving with it) (`0` return value cancels retry).
|
|
1260
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
|
+
|
|
1261
1266
|
By default, it retries *only* on the specified methods, status codes, and on these network errors:
|
|
1262
1267
|
|
|
1263
1268
|
- `ETIMEDOUT`: One of the [timeout](#timeout) limits were reached.
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -164,7 +164,7 @@ By default, Got will retry on failure. To disable this option, set [`options.ret
|
|
|
164
164
|
| Cookies (out-of-the-box) | :heavy_check_mark: | :x: | :x: | :x: | :x: |
|
|
165
165
|
| Follows redirects | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
|
|
166
166
|
| Retries on failure | :heavy_check_mark: | :x: | :heavy_check_mark: | :x: | :heavy_check_mark: |
|
|
167
|
-
| Progress events | :heavy_check_mark: | :x: | :heavy_check_mark
|
|
167
|
+
| Progress events | :heavy_check_mark: | :x: | :heavy_check_mark: | Browser only | :heavy_check_mark: |
|
|
168
168
|
| Handles gzip/deflate | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
|
|
169
169
|
| Advanced timeouts | :heavy_check_mark: | :x: | :x: | :x: | :x: |
|
|
170
170
|
| Timings | :heavy_check_mark: | :x: | :x: | :x: | :x: |
|
|
@@ -187,7 +187,6 @@ By default, Got will retry on failure. To disable this option, set [`options.ret
|
|
|
187
187
|
|
|
188
188
|
\* It's almost API compatible with the browser `fetch` API.\
|
|
189
189
|
\*\* Need to switch the protocol manually. Doesn't accept PUSH streams and doesn't reuse HTTP/2 sessions.\
|
|
190
|
-
\*\*\* Currently, only `DownloadProgress` event is supported, `UploadProgress` event is not supported.\
|
|
191
190
|
¹ Requires Node.js 15.10.0 or above.\
|
|
192
191
|
:sparkle: Almost-stable feature, but the API may change. Don't hesitate to try it out!\
|
|
193
192
|
:grey_question: Feature in early stage of development. Very experimental.
|