got 11.6.1 → 11.6.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.
- package/dist/source/core/index.js +11 -7
- package/package.json +1 -1
- package/readme.md +10 -8
|
@@ -341,7 +341,7 @@ class Request extends stream_1.Duplex {
|
|
|
341
341
|
})(options);
|
|
342
342
|
}
|
|
343
343
|
static normalizeArguments(url, options, defaults) {
|
|
344
|
-
var _a, _b, _c, _d;
|
|
344
|
+
var _a, _b, _c, _d, _e;
|
|
345
345
|
const rawOptions = options;
|
|
346
346
|
if (is_1.default.object(url) && !is_1.default.urlInstance(url)) {
|
|
347
347
|
options = { ...defaults, ...url, ...options };
|
|
@@ -453,15 +453,15 @@ class Request extends stream_1.Duplex {
|
|
|
453
453
|
options.username = (_b = options.username) !== null && _b !== void 0 ? _b : '';
|
|
454
454
|
options.password = (_c = options.password) !== null && _c !== void 0 ? _c : '';
|
|
455
455
|
// `options.prefixUrl` & `options.url`
|
|
456
|
-
if (options.prefixUrl) {
|
|
456
|
+
if (is_1.default.undefined(options.prefixUrl)) {
|
|
457
|
+
options.prefixUrl = (_d = defaults === null || defaults === void 0 ? void 0 : defaults.prefixUrl) !== null && _d !== void 0 ? _d : '';
|
|
458
|
+
}
|
|
459
|
+
else {
|
|
457
460
|
options.prefixUrl = options.prefixUrl.toString();
|
|
458
461
|
if (options.prefixUrl !== '' && !options.prefixUrl.endsWith('/')) {
|
|
459
462
|
options.prefixUrl += '/';
|
|
460
463
|
}
|
|
461
464
|
}
|
|
462
|
-
else {
|
|
463
|
-
options.prefixUrl = '';
|
|
464
|
-
}
|
|
465
465
|
if (is_1.default.string(options.url)) {
|
|
466
466
|
if (options.url.startsWith('/')) {
|
|
467
467
|
throw new Error('`input` must not start with a slash when using `prefixUrl`');
|
|
@@ -660,7 +660,7 @@ class Request extends stream_1.Duplex {
|
|
|
660
660
|
}
|
|
661
661
|
}
|
|
662
662
|
}
|
|
663
|
-
options.maxRedirects = (
|
|
663
|
+
options.maxRedirects = (_e = options.maxRedirects) !== null && _e !== void 0 ? _e : 0;
|
|
664
664
|
// Set non-enumerable properties
|
|
665
665
|
exports.setNonEnumerableProperties([defaults, rawOptions], options);
|
|
666
666
|
return normalize_arguments_1.default(options, defaults);
|
|
@@ -1182,9 +1182,9 @@ class Request extends stream_1.Duplex {
|
|
|
1182
1182
|
response.setEncoding(this._readableState.encoding);
|
|
1183
1183
|
try {
|
|
1184
1184
|
response.rawBody = await get_buffer_1.default(response);
|
|
1185
|
+
response.body = response.rawBody.toString();
|
|
1185
1186
|
}
|
|
1186
1187
|
catch (_a) { }
|
|
1187
|
-
response.body = response.rawBody.toString();
|
|
1188
1188
|
}
|
|
1189
1189
|
if (this.listenerCount('retry') !== 0) {
|
|
1190
1190
|
let backoff;
|
|
@@ -1280,6 +1280,10 @@ class Request extends stream_1.Duplex {
|
|
|
1280
1280
|
}
|
|
1281
1281
|
}
|
|
1282
1282
|
_writeRequest(chunk, encoding, callback) {
|
|
1283
|
+
if (this[kRequest].destroyed) {
|
|
1284
|
+
// Probably the `ClientRequest` instance will throw
|
|
1285
|
+
return;
|
|
1286
|
+
}
|
|
1283
1287
|
this._progressCallbacks.push(() => {
|
|
1284
1288
|
this[kUploadedSize] += Buffer.byteLength(chunk, encoding);
|
|
1285
1289
|
const progress = this.uploadProgress;
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -519,6 +519,8 @@ Delays between retries counts with function `1000 * Math.pow(2, retry - 1) + Mat
|
|
|
519
519
|
|
|
520
520
|
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. The function must return a delay in milliseconds (or a Promise resolving with it) (`0` return value cancels retry).
|
|
521
521
|
|
|
522
|
+
**Note:** The `calculateDelay` function is responsible for the entire cache mechanism, including the `limit` property. To support it, you need to check whether `computedValue` is different than `0`.
|
|
523
|
+
|
|
522
524
|
By default, it retries *only* on the specified methods, status codes, and on these network errors:
|
|
523
525
|
- `ETIMEDOUT`: One of the [timeout](#timeout) limits were reached.
|
|
524
526
|
- `ECONNRESET`: Connection was forcibly closed by a peer.
|
|
@@ -726,7 +728,7 @@ Called with plain [request options](#options), right before their normalization.
|
|
|
726
728
|
See the [Request migration guide](documentation/migration-guides.md#breaking-changes) for an example.
|
|
727
729
|
|
|
728
730
|
**Note #1:** This hook must be synchronous!\
|
|
729
|
-
**Note #2:** Errors in this hook will be converted into an instances of [`RequestError`](#
|
|
731
|
+
**Note #2:** Errors in this hook will be converted into an instances of [`RequestError`](#gotrequesterror).\
|
|
730
732
|
**Note #3:** The options object may not have a `url` property. To modify it, use a `beforeRequest` hook instead.
|
|
731
733
|
|
|
732
734
|
###### hooks.beforeRequest
|
|
@@ -1320,7 +1322,7 @@ The same as `response.socket`.
|
|
|
1320
1322
|
|
|
1321
1323
|
##### .on('error', error)
|
|
1322
1324
|
|
|
1323
|
-
The emitted `error` is an instance of [`RequestError`](#
|
|
1325
|
+
The emitted `error` is an instance of [`RequestError`](#gotrequesterror).
|
|
1324
1326
|
|
|
1325
1327
|
#### Pagination
|
|
1326
1328
|
|
|
@@ -2194,12 +2196,12 @@ The Electron `net` module is not consistent with the Node.js `http` module. See
|
|
|
2194
2196
|
[ab]: https://badgen.net/travis/axios/axios?label
|
|
2195
2197
|
[sb]: https://badgen.net/travis/visionmedia/superagent?label
|
|
2196
2198
|
|
|
2197
|
-
[g5]: https://travis-ci.
|
|
2198
|
-
[k5]: https://travis-ci.
|
|
2199
|
-
[r5]: https://travis-ci.org/request/request
|
|
2200
|
-
[n5]: https://travis-ci.org/bitinn/node-fetch
|
|
2201
|
-
[a5]: https://travis-ci.org/axios/axios
|
|
2202
|
-
[s5]: https://travis-ci.org/visionmedia/superagent
|
|
2199
|
+
[g5]: https://travis-ci.com/github/sindresorhus/got
|
|
2200
|
+
[k5]: https://travis-ci.com/github/sindresorhus/ky
|
|
2201
|
+
[r5]: https://travis-ci.org/github/request/request
|
|
2202
|
+
[n5]: https://travis-ci.org/github/bitinn/node-fetch
|
|
2203
|
+
[a5]: https://travis-ci.org/github/axios/axios
|
|
2204
|
+
[s5]: https://travis-ci.org/github/visionmedia/superagent
|
|
2203
2205
|
|
|
2204
2206
|
<!-- BUGS -->
|
|
2205
2207
|
[gbg]: https://badgen.net/github/label-issues/sindresorhus/got/bug/open?label
|