got 12.0.3 → 12.2.0
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/errors.d.ts +6 -0
- package/dist/source/core/errors.js +10 -0
- package/dist/source/core/index.d.ts +9 -2
- package/dist/source/core/index.js +21 -51
- package/dist/source/core/options.d.ts +34 -0
- package/dist/source/core/options.js +45 -3
- package/dist/source/core/response.d.ts +8 -1
- package/dist/source/core/utils/is-unix-socket-url.d.ts +3 -0
- package/dist/source/core/utils/is-unix-socket-url.js +4 -0
- package/dist/source/index.d.ts +1 -1
- package/dist/source/types.d.ts +9 -0
- package/package.json +18 -17
- package/readme.md +69 -3
|
@@ -81,4 +81,10 @@ An error which always triggers a new retry when thrown.
|
|
|
81
81
|
export declare class RetryError extends RequestError {
|
|
82
82
|
constructor(request: Request);
|
|
83
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
An error to be thrown when the request is aborted by AbortController.
|
|
86
|
+
*/
|
|
87
|
+
export declare class AbortError extends RequestError {
|
|
88
|
+
constructor(request: Request);
|
|
89
|
+
}
|
|
84
90
|
export {};
|
|
@@ -166,3 +166,13 @@ export class RetryError extends RequestError {
|
|
|
166
166
|
this.code = 'ERR_RETRYING';
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
|
+
/**
|
|
170
|
+
An error to be thrown when the request is aborted by AbortController.
|
|
171
|
+
*/
|
|
172
|
+
export class AbortError extends RequestError {
|
|
173
|
+
constructor(request) {
|
|
174
|
+
super('This operation was aborted.', {}, request);
|
|
175
|
+
this.code = 'ERR_ABORTED';
|
|
176
|
+
this.name = 'AbortError';
|
|
177
|
+
}
|
|
178
|
+
}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
/// <reference types="node" />
|
|
4
|
+
/// <reference types="node" />
|
|
5
|
+
/// <reference types="node" />
|
|
6
|
+
/// <reference types="node" />
|
|
2
7
|
import { Duplex } from 'node:stream';
|
|
3
8
|
import { URL } from 'node:url';
|
|
4
9
|
import { ServerResponse } from 'node:http';
|
|
@@ -26,6 +31,8 @@ export declare type GotEventFunction<T> =
|
|
|
26
31
|
|
|
27
32
|
@example
|
|
28
33
|
```
|
|
34
|
+
import got from 'got';
|
|
35
|
+
|
|
29
36
|
got.stream('https://github.com')
|
|
30
37
|
.on('request', request => setTimeout(() => request.destroy(), 50));
|
|
31
38
|
```
|
|
@@ -55,6 +62,8 @@ If the `content-length` header is missing, `total` will be `undefined`.
|
|
|
55
62
|
|
|
56
63
|
@example
|
|
57
64
|
```
|
|
65
|
+
import got from 'got';
|
|
66
|
+
|
|
58
67
|
const response = await got('https://sindresorhus.com')
|
|
59
68
|
.on('downloadProgress', progress => {
|
|
60
69
|
// Report download progress
|
|
@@ -121,8 +130,6 @@ export default class Request extends Duplex implements RequestEvents<Request> {
|
|
|
121
130
|
end?: boolean;
|
|
122
131
|
}): T;
|
|
123
132
|
unpipe<T extends NodeJS.WritableStream>(destination: T): this;
|
|
124
|
-
private _lockWrite;
|
|
125
|
-
private _unlockWrite;
|
|
126
133
|
private _finalizeBody;
|
|
127
134
|
private _onResponseBase;
|
|
128
135
|
private _setRawBody;
|
|
@@ -8,7 +8,7 @@ import CacheableRequest from 'cacheable-request';
|
|
|
8
8
|
import decompressResponse from 'decompress-response';
|
|
9
9
|
import is from '@sindresorhus/is';
|
|
10
10
|
import { buffer as getBuffer } from 'get-stream';
|
|
11
|
-
import { FormDataEncoder, isFormDataLike } from 'form-data-encoder';
|
|
11
|
+
import { FormDataEncoder, isFormData as isFormDataLike } from 'form-data-encoder';
|
|
12
12
|
import getBodySize from './utils/get-body-size.js';
|
|
13
13
|
import isFormData from './utils/is-form-data.js';
|
|
14
14
|
import proxyEvents from './utils/proxy-events.js';
|
|
@@ -19,7 +19,8 @@ import calculateRetryDelay from './calculate-retry-delay.js';
|
|
|
19
19
|
import Options from './options.js';
|
|
20
20
|
import { isResponseOk } from './response.js';
|
|
21
21
|
import isClientRequest from './utils/is-client-request.js';
|
|
22
|
-
import
|
|
22
|
+
import isUnixSocketURL from './utils/is-unix-socket-url.js';
|
|
23
|
+
import { RequestError, ReadError, MaxRedirectsError, HTTPError, TimeoutError, UploadError, CacheError, AbortError, } from './errors.js';
|
|
23
24
|
const supportsBrotli = is.string(process.versions.brotli);
|
|
24
25
|
const methodsWithoutBody = new Set(['GET', 'HEAD']);
|
|
25
26
|
const cacheableStore = new WeakableMap();
|
|
@@ -40,6 +41,7 @@ export default class Request extends Duplex {
|
|
|
40
41
|
// It needs to be zero because we're just proxying the data to another stream
|
|
41
42
|
highWaterMark: 0,
|
|
42
43
|
});
|
|
44
|
+
// @ts-expect-error - Ignoring for now.
|
|
43
45
|
Object.defineProperty(this, 'constructor', {
|
|
44
46
|
enumerable: true,
|
|
45
47
|
configurable: true,
|
|
@@ -201,24 +203,6 @@ export default class Request extends Duplex {
|
|
|
201
203
|
this.redirectUrls = [];
|
|
202
204
|
this.retryCount = 0;
|
|
203
205
|
this._stopRetry = noop;
|
|
204
|
-
const unlockWrite = () => {
|
|
205
|
-
this._unlockWrite();
|
|
206
|
-
};
|
|
207
|
-
const lockWrite = () => {
|
|
208
|
-
this._lockWrite();
|
|
209
|
-
};
|
|
210
|
-
this.on('pipe', (source) => {
|
|
211
|
-
source.prependListener('data', unlockWrite);
|
|
212
|
-
source.on('data', lockWrite);
|
|
213
|
-
source.prependListener('end', unlockWrite);
|
|
214
|
-
source.on('end', lockWrite);
|
|
215
|
-
});
|
|
216
|
-
this.on('unpipe', (source) => {
|
|
217
|
-
source.off('data', unlockWrite);
|
|
218
|
-
source.off('data', lockWrite);
|
|
219
|
-
source.off('end', unlockWrite);
|
|
220
|
-
source.off('end', lockWrite);
|
|
221
|
-
});
|
|
222
206
|
this.on('pipe', source => {
|
|
223
207
|
if (source.headers) {
|
|
224
208
|
Object.assign(this.options.headers, source.headers);
|
|
@@ -250,12 +234,15 @@ export default class Request extends Duplex {
|
|
|
250
234
|
};
|
|
251
235
|
return;
|
|
252
236
|
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
this._lockWrite();
|
|
237
|
+
if (this.options.signal?.aborted) {
|
|
238
|
+
this.destroy(new AbortError(this));
|
|
256
239
|
}
|
|
240
|
+
this.options.signal?.addEventListener('abort', () => {
|
|
241
|
+
this.destroy(new AbortError(this));
|
|
242
|
+
});
|
|
257
243
|
// Important! If you replace `body` in a handler with another stream, make sure it's readable first.
|
|
258
244
|
// The below is run only once.
|
|
245
|
+
const { body } = this.options;
|
|
259
246
|
if (is.nodeStream(body)) {
|
|
260
247
|
body.once('error', error => {
|
|
261
248
|
if (this._flushed) {
|
|
@@ -492,17 +479,6 @@ export default class Request extends Duplex {
|
|
|
492
479
|
super.unpipe(destination);
|
|
493
480
|
return this;
|
|
494
481
|
}
|
|
495
|
-
_lockWrite() {
|
|
496
|
-
const onLockedWrite = () => {
|
|
497
|
-
throw new TypeError('The payload has been already provided');
|
|
498
|
-
};
|
|
499
|
-
this.write = onLockedWrite;
|
|
500
|
-
this.end = onLockedWrite;
|
|
501
|
-
}
|
|
502
|
-
_unlockWrite() {
|
|
503
|
-
this.write = super.write;
|
|
504
|
-
this.end = super.end;
|
|
505
|
-
}
|
|
506
482
|
async _finalizeBody() {
|
|
507
483
|
const { options } = this;
|
|
508
484
|
const { headers } = options;
|
|
@@ -563,12 +539,6 @@ export default class Request extends Duplex {
|
|
|
563
539
|
headers['content-length'] = String(uploadBodySize);
|
|
564
540
|
}
|
|
565
541
|
}
|
|
566
|
-
else if (cannotHaveBody) {
|
|
567
|
-
this._lockWrite();
|
|
568
|
-
}
|
|
569
|
-
else {
|
|
570
|
-
this._unlockWrite();
|
|
571
|
-
}
|
|
572
542
|
if (options.responseType === 'json' && !('accept' in options.headers)) {
|
|
573
543
|
options.headers.accept = 'application/json';
|
|
574
544
|
}
|
|
@@ -595,6 +565,7 @@ export default class Request extends Duplex {
|
|
|
595
565
|
typedResponse.isFromCache = this._nativeResponse.fromCache ?? false;
|
|
596
566
|
typedResponse.ip = this.ip;
|
|
597
567
|
typedResponse.retryCount = this.retryCount;
|
|
568
|
+
typedResponse.ok = isResponseOk(typedResponse);
|
|
598
569
|
this._isFromCache = typedResponse.isFromCache;
|
|
599
570
|
this._responseSize = Number(response.headers['content-length']) || undefined;
|
|
600
571
|
this.response = typedResponse;
|
|
@@ -668,6 +639,10 @@ export default class Request extends Duplex {
|
|
|
668
639
|
// We need this in order to support UTF-8
|
|
669
640
|
const redirectBuffer = Buffer.from(response.headers.location, 'binary').toString();
|
|
670
641
|
const redirectUrl = new URL(redirectBuffer, url);
|
|
642
|
+
if (!isUnixSocketURL(url) && isUnixSocketURL(redirectUrl)) {
|
|
643
|
+
this._beforeError(new RequestError('Cannot redirect to UNIX socket', {}, this));
|
|
644
|
+
return;
|
|
645
|
+
}
|
|
671
646
|
// Redirecting to a different site, clear sensitive data.
|
|
672
647
|
if (redirectUrl.hostname !== url.hostname || redirectUrl.port !== url.port) {
|
|
673
648
|
if ('host' in updatedOptions.headers) {
|
|
@@ -829,17 +804,12 @@ export default class Request extends Duplex {
|
|
|
829
804
|
}
|
|
830
805
|
})();
|
|
831
806
|
}
|
|
832
|
-
else {
|
|
833
|
-
this.
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
}
|
|
839
|
-
else if (this._cannotHaveBody || this._noPipe) {
|
|
840
|
-
currentRequest.end();
|
|
841
|
-
this._lockWrite();
|
|
842
|
-
}
|
|
807
|
+
else if (!is.undefined(body)) {
|
|
808
|
+
this._writeRequest(body, undefined, () => { });
|
|
809
|
+
currentRequest.end();
|
|
810
|
+
}
|
|
811
|
+
else if (this._cannotHaveBody || this._noPipe) {
|
|
812
|
+
currentRequest.end();
|
|
843
813
|
}
|
|
844
814
|
}
|
|
845
815
|
_prepareCache(cache) {
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
/// <reference types="node" />
|
|
4
|
+
/// <reference types="node" />
|
|
5
|
+
/// <reference types="node" />
|
|
6
|
+
/// <reference types="node" />
|
|
7
|
+
/// <reference types="node" />
|
|
8
|
+
/// <reference types="node" />
|
|
9
|
+
/// <reference types="node" />
|
|
2
10
|
import { Buffer } from 'node:buffer';
|
|
3
11
|
import { URL, URLSearchParams } from 'node:url';
|
|
4
12
|
import { checkServerIdentity } from 'node:tls';
|
|
@@ -731,6 +739,28 @@ export default class Options {
|
|
|
731
739
|
get cookieJar(): PromiseCookieJar | ToughCookieJar | undefined;
|
|
732
740
|
set cookieJar(value: PromiseCookieJar | ToughCookieJar | undefined);
|
|
733
741
|
/**
|
|
742
|
+
You can abort the `request` using [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).
|
|
743
|
+
|
|
744
|
+
*Requires Node.js 16 or later.*
|
|
745
|
+
|
|
746
|
+
@example
|
|
747
|
+
```
|
|
748
|
+
import got from 'got';
|
|
749
|
+
|
|
750
|
+
const abortController = new AbortController();
|
|
751
|
+
|
|
752
|
+
const request = got('https://httpbin.org/anything', {
|
|
753
|
+
signal: abortController.signal
|
|
754
|
+
});
|
|
755
|
+
|
|
756
|
+
setTimeout(() => {
|
|
757
|
+
abortController.abort();
|
|
758
|
+
}, 100);
|
|
759
|
+
```
|
|
760
|
+
*/
|
|
761
|
+
get signal(): any | undefined;
|
|
762
|
+
set signal(value: any | undefined);
|
|
763
|
+
/**
|
|
734
764
|
Ignore invalid cookies instead of throwing an error.
|
|
735
765
|
Only useful when the `cookieJar` option has been set. Not recommended.
|
|
736
766
|
|
|
@@ -1096,6 +1126,8 @@ export default class Options {
|
|
|
1096
1126
|
set setHost(value: boolean);
|
|
1097
1127
|
get maxHeaderSize(): number | undefined;
|
|
1098
1128
|
set maxHeaderSize(value: number | undefined);
|
|
1129
|
+
get enableUnixSockets(): boolean;
|
|
1130
|
+
set enableUnixSockets(value: boolean);
|
|
1099
1131
|
toJSON(): {
|
|
1100
1132
|
headers: Headers;
|
|
1101
1133
|
timeout: Delays;
|
|
@@ -1112,6 +1144,7 @@ export default class Options {
|
|
|
1112
1144
|
form: Record<string, any> | undefined;
|
|
1113
1145
|
url: string | URL | undefined;
|
|
1114
1146
|
cookieJar: PromiseCookieJar | ToughCookieJar | undefined;
|
|
1147
|
+
signal: any;
|
|
1115
1148
|
ignoreInvalidCookies: boolean;
|
|
1116
1149
|
searchParams: string | SearchParameters | URLSearchParams | undefined;
|
|
1117
1150
|
dnsLookup: {
|
|
@@ -1147,6 +1180,7 @@ export default class Options {
|
|
|
1147
1180
|
pagination: PaginationOptions<unknown, unknown>;
|
|
1148
1181
|
setHost: boolean;
|
|
1149
1182
|
maxHeaderSize: number | undefined;
|
|
1183
|
+
enableUnixSockets: boolean;
|
|
1150
1184
|
};
|
|
1151
1185
|
createNativeRequestOptions(): {
|
|
1152
1186
|
ALPNProtocols: string[] | undefined;
|
|
@@ -9,9 +9,9 @@ import is, { assert } from '@sindresorhus/is';
|
|
|
9
9
|
import lowercaseKeys from 'lowercase-keys';
|
|
10
10
|
import CacheableLookup from 'cacheable-lookup';
|
|
11
11
|
import http2wrapper from 'http2-wrapper';
|
|
12
|
-
import {
|
|
12
|
+
import { isFormData } from 'form-data-encoder';
|
|
13
13
|
import parseLinkHeader from './parse-link-header.js';
|
|
14
|
-
const [major, minor] = process.versions.node.split('.').map(
|
|
14
|
+
const [major, minor] = process.versions.node.split('.').map(Number);
|
|
15
15
|
function validateSearchParameters(searchParameters) {
|
|
16
16
|
// eslint-disable-next-line guard-for-in
|
|
17
17
|
for (const key in searchParameters) {
|
|
@@ -180,6 +180,8 @@ const defaultInternals = {
|
|
|
180
180
|
},
|
|
181
181
|
setHost: true,
|
|
182
182
|
maxHeaderSize: undefined,
|
|
183
|
+
signal: undefined,
|
|
184
|
+
enableUnixSockets: true,
|
|
183
185
|
};
|
|
184
186
|
const cloneInternals = (internals) => {
|
|
185
187
|
const { hooks, retry } = internals;
|
|
@@ -607,7 +609,7 @@ export default class Options {
|
|
|
607
609
|
return this._internals.body;
|
|
608
610
|
}
|
|
609
611
|
set body(value) {
|
|
610
|
-
assert.any([is.string, is.buffer, is.nodeStream, is.generator, is.asyncGenerator,
|
|
612
|
+
assert.any([is.string, is.buffer, is.nodeStream, is.generator, is.asyncGenerator, isFormData, is.undefined], value);
|
|
611
613
|
if (is.nodeStream(value)) {
|
|
612
614
|
assert.truthy(value.readable);
|
|
613
615
|
}
|
|
@@ -709,6 +711,9 @@ export default class Options {
|
|
|
709
711
|
this._internals.searchParams = undefined;
|
|
710
712
|
}
|
|
711
713
|
if (url.hostname === 'unix') {
|
|
714
|
+
if (!this._internals.enableUnixSockets) {
|
|
715
|
+
throw new Error('Using UNIX domain sockets but option `enableUnixSockets` is not enabled');
|
|
716
|
+
}
|
|
712
717
|
const matches = /(?<socketPath>.+?):(?<path>.+)/.exec(`${url.pathname}${url.search}`);
|
|
713
718
|
if (matches?.groups) {
|
|
714
719
|
const { socketPath, path } = matches.groups;
|
|
@@ -756,6 +761,35 @@ export default class Options {
|
|
|
756
761
|
}
|
|
757
762
|
}
|
|
758
763
|
/**
|
|
764
|
+
You can abort the `request` using [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).
|
|
765
|
+
|
|
766
|
+
*Requires Node.js 16 or later.*
|
|
767
|
+
|
|
768
|
+
@example
|
|
769
|
+
```
|
|
770
|
+
import got from 'got';
|
|
771
|
+
|
|
772
|
+
const abortController = new AbortController();
|
|
773
|
+
|
|
774
|
+
const request = got('https://httpbin.org/anything', {
|
|
775
|
+
signal: abortController.signal
|
|
776
|
+
});
|
|
777
|
+
|
|
778
|
+
setTimeout(() => {
|
|
779
|
+
abortController.abort();
|
|
780
|
+
}, 100);
|
|
781
|
+
```
|
|
782
|
+
*/
|
|
783
|
+
// TODO: Replace `any` with `AbortSignal` when targeting Node 16.
|
|
784
|
+
get signal() {
|
|
785
|
+
return this._internals.signal;
|
|
786
|
+
}
|
|
787
|
+
// TODO: Replace `any` with `AbortSignal` when targeting Node 16.
|
|
788
|
+
set signal(value) {
|
|
789
|
+
assert.object(value);
|
|
790
|
+
this._internals.signal = value;
|
|
791
|
+
}
|
|
792
|
+
/**
|
|
759
793
|
Ignore invalid cookies instead of throwing an error.
|
|
760
794
|
Only useful when the `cookieJar` option has been set. Not recommended.
|
|
761
795
|
|
|
@@ -1498,6 +1532,13 @@ export default class Options {
|
|
|
1498
1532
|
assert.any([is.number, is.undefined], value);
|
|
1499
1533
|
this._internals.maxHeaderSize = value;
|
|
1500
1534
|
}
|
|
1535
|
+
get enableUnixSockets() {
|
|
1536
|
+
return this._internals.enableUnixSockets;
|
|
1537
|
+
}
|
|
1538
|
+
set enableUnixSockets(value) {
|
|
1539
|
+
assert.boolean(value);
|
|
1540
|
+
this._internals.enableUnixSockets = value;
|
|
1541
|
+
}
|
|
1501
1542
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
1502
1543
|
toJSON() {
|
|
1503
1544
|
return { ...this._internals };
|
|
@@ -1606,5 +1647,6 @@ export default class Options {
|
|
|
1606
1647
|
Object.freeze(options.retry.methods);
|
|
1607
1648
|
Object.freeze(options.retry.statusCodes);
|
|
1608
1649
|
Object.freeze(options.context);
|
|
1650
|
+
Object.freeze(options.signal);
|
|
1609
1651
|
}
|
|
1610
1652
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
2
3
|
import type { Buffer } from 'node:buffer';
|
|
3
4
|
import type { URL } from 'node:url';
|
|
4
5
|
import type { IncomingMessageWithTimings, Timings } from '@szmarczak/http-timer';
|
|
@@ -80,6 +81,12 @@ export interface PlainResponse extends IncomingMessageWithTimings {
|
|
|
80
81
|
The result of the request.
|
|
81
82
|
*/
|
|
82
83
|
body?: unknown;
|
|
84
|
+
/**
|
|
85
|
+
Whether the response was successful.
|
|
86
|
+
|
|
87
|
+
__Note__: Got throws automatically when `response.ok` is `false` and `throwHttpErrors` is `true`.
|
|
88
|
+
*/
|
|
89
|
+
ok: boolean;
|
|
83
90
|
}
|
|
84
91
|
export interface Response<T = unknown> extends PlainResponse {
|
|
85
92
|
/**
|
|
@@ -100,4 +107,4 @@ export declare class ParseError extends RequestError {
|
|
|
100
107
|
readonly response: Response;
|
|
101
108
|
constructor(error: Error, response: Response);
|
|
102
109
|
}
|
|
103
|
-
export declare const parseBody: (response: Response, responseType: ResponseType, parseJson: ParseJsonFunction, encoding?: BufferEncoding
|
|
110
|
+
export declare const parseBody: (response: Response, responseType: ResponseType, parseJson: ParseJsonFunction, encoding?: BufferEncoding) => unknown;
|
package/dist/source/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export * from './core/response.js';
|
|
|
7
7
|
export type { default as Request } from './core/index.js';
|
|
8
8
|
export * from './core/index.js';
|
|
9
9
|
export * from './core/errors.js';
|
|
10
|
-
export { Delays } from './core/timed-out.js';
|
|
10
|
+
export type { Delays } from './core/timed-out.js';
|
|
11
11
|
export { default as calculateRetryDelay } from './core/calculate-retry-delay.js';
|
|
12
12
|
export * from './as-promise/types.js';
|
|
13
13
|
export * from './types.js';
|
package/dist/source/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
2
3
|
import type { Buffer } from 'node:buffer';
|
|
3
4
|
import type { URL } from 'node:url';
|
|
4
5
|
import type { CancelableRequest } from './as-promise/types.js';
|
|
@@ -109,6 +110,8 @@ export interface GotPaginate {
|
|
|
109
110
|
|
|
110
111
|
@example
|
|
111
112
|
```
|
|
113
|
+
import got from 'got';
|
|
114
|
+
|
|
112
115
|
const countLimit = 10;
|
|
113
116
|
|
|
114
117
|
const pagination = got.paginate('https://api.github.com/repos/sindresorhus/got/commits', {
|
|
@@ -130,6 +133,8 @@ export interface GotPaginate {
|
|
|
130
133
|
|
|
131
134
|
@example
|
|
132
135
|
```
|
|
136
|
+
import got from 'got';
|
|
137
|
+
|
|
133
138
|
const countLimit = 10;
|
|
134
139
|
|
|
135
140
|
const results = await got.paginate.all('https://api.github.com/repos/sindresorhus/got/commits', {
|
|
@@ -203,6 +208,8 @@ export interface Got extends Record<HTTPAlias, GotRequestFunction>, GotRequestFu
|
|
|
203
208
|
|
|
204
209
|
@example
|
|
205
210
|
```
|
|
211
|
+
import got from 'got';
|
|
212
|
+
|
|
206
213
|
const countLimit = 10;
|
|
207
214
|
|
|
208
215
|
const pagination = got.paginate('https://api.github.com/repos/sindresorhus/got/commits', {
|
|
@@ -234,6 +241,8 @@ export interface Got extends Record<HTTPAlias, GotRequestFunction>, GotRequestFu
|
|
|
234
241
|
|
|
235
242
|
@example
|
|
236
243
|
```
|
|
244
|
+
import got from 'got';
|
|
245
|
+
|
|
237
246
|
const client = got.extend({
|
|
238
247
|
prefixUrl: 'https://example.com',
|
|
239
248
|
headers: {
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "got",
|
|
3
|
-
"version": "12.0
|
|
3
|
+
"version": "12.2.0",
|
|
4
4
|
"description": "Human-friendly and powerful HTTP request library for Node.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "sindresorhus/got",
|
|
7
7
|
"funding": "https://github.com/sindresorhus/got?sponsor=1",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"exports": "./dist/source/index.js",
|
|
10
|
+
"types": "./dist/source/index.d.ts",
|
|
10
11
|
"engines": {
|
|
11
12
|
"node": ">=14.16"
|
|
12
13
|
},
|
|
@@ -44,14 +45,14 @@
|
|
|
44
45
|
"ky"
|
|
45
46
|
],
|
|
46
47
|
"dependencies": {
|
|
47
|
-
"@sindresorhus/is": "^
|
|
48
|
+
"@sindresorhus/is": "^5.2.0",
|
|
48
49
|
"@szmarczak/http-timer": "^5.0.1",
|
|
49
50
|
"@types/cacheable-request": "^6.0.2",
|
|
50
51
|
"@types/responselike": "^1.0.0",
|
|
51
52
|
"cacheable-lookup": "^6.0.4",
|
|
52
53
|
"cacheable-request": "^7.0.2",
|
|
53
54
|
"decompress-response": "^6.0.0",
|
|
54
|
-
"form-data-encoder": "
|
|
55
|
+
"form-data-encoder": "^2.0.1",
|
|
55
56
|
"get-stream": "^6.0.1",
|
|
56
57
|
"http2-wrapper": "^2.1.10",
|
|
57
58
|
"lowercase-keys": "^3.0.0",
|
|
@@ -59,12 +60,12 @@
|
|
|
59
60
|
"responselike": "^2.0.0"
|
|
60
61
|
},
|
|
61
62
|
"devDependencies": {
|
|
62
|
-
"@hapi/bourne": "^
|
|
63
|
+
"@hapi/bourne": "^3.0.0",
|
|
63
64
|
"@sindresorhus/tsconfig": "^2.0.0",
|
|
64
65
|
"@sinonjs/fake-timers": "^9.1.1",
|
|
65
66
|
"@types/benchmark": "^2.1.1",
|
|
66
67
|
"@types/express": "^4.17.13",
|
|
67
|
-
"@types/node": "^
|
|
68
|
+
"@types/node": "^18.0.1",
|
|
68
69
|
"@types/pem": "^1.9.6",
|
|
69
70
|
"@types/pify": "^5.0.1",
|
|
70
71
|
"@types/readable-stream": "^2.3.13",
|
|
@@ -73,7 +74,7 @@
|
|
|
73
74
|
"@types/sinonjs__fake-timers": "^8.1.1",
|
|
74
75
|
"@types/tough-cookie": "^4.0.1",
|
|
75
76
|
"ava": "^3.15.0",
|
|
76
|
-
"axios": "^0.
|
|
77
|
+
"axios": "^0.27.2",
|
|
77
78
|
"benchmark": "^2.1.4",
|
|
78
79
|
"bluebird": "^3.7.2",
|
|
79
80
|
"body-parser": "^1.19.2",
|
|
@@ -90,20 +91,19 @@
|
|
|
90
91
|
"nyc": "^15.1.0",
|
|
91
92
|
"p-event": "^5.0.1",
|
|
92
93
|
"pem": "^1.14.6",
|
|
93
|
-
"pify": "^
|
|
94
|
-
"readable-stream": "^
|
|
94
|
+
"pify": "^6.0.0",
|
|
95
|
+
"readable-stream": "^4.0.0",
|
|
95
96
|
"request": "^2.88.2",
|
|
96
|
-
"sinon": "^
|
|
97
|
+
"sinon": "^14.0.0",
|
|
97
98
|
"slow-stream": "0.0.4",
|
|
98
|
-
"tempy": "^
|
|
99
|
+
"tempy": "^3.0.0",
|
|
99
100
|
"then-busboy": "^5.1.1",
|
|
100
101
|
"to-readable-stream": "^3.0.0",
|
|
101
102
|
"tough-cookie": "^4.0.0",
|
|
102
|
-
"ts-node": "^10.
|
|
103
|
-
"typescript": "4.
|
|
104
|
-
"xo": "^0.
|
|
103
|
+
"ts-node": "^10.8.2",
|
|
104
|
+
"typescript": "^4.7.4",
|
|
105
|
+
"xo": "^0.50.0"
|
|
105
106
|
},
|
|
106
|
-
"types": "dist/source",
|
|
107
107
|
"sideEffects": false,
|
|
108
108
|
"ava": {
|
|
109
109
|
"files": [
|
|
@@ -140,9 +140,9 @@
|
|
|
140
140
|
],
|
|
141
141
|
"rules": {
|
|
142
142
|
"@typescript-eslint/no-empty-function": "off",
|
|
143
|
-
"
|
|
144
|
-
"
|
|
145
|
-
"
|
|
143
|
+
"n/no-deprecated-api": "off",
|
|
144
|
+
"n/prefer-global/url": "off",
|
|
145
|
+
"n/prefer-global/url-search-params": "off",
|
|
146
146
|
"@typescript-eslint/no-implicit-any-catch": "off",
|
|
147
147
|
"unicorn/prefer-node-protocol": "off",
|
|
148
148
|
"ava/assertion-arguments": "off",
|
|
@@ -151,6 +151,7 @@
|
|
|
151
151
|
"@typescript-eslint/no-unsafe-assignment": "off",
|
|
152
152
|
"@typescript-eslint/no-unsafe-call": "off",
|
|
153
153
|
"@typescript-eslint/await-thenable": "off",
|
|
154
|
+
"@typescript-eslint/no-redundant-type-constituents": "off",
|
|
154
155
|
"no-lone-blocks": "off",
|
|
155
156
|
"unicorn/no-await-expression-member": "off"
|
|
156
157
|
}
|
package/readme.md
CHANGED
|
@@ -46,6 +46,72 @@
|
|
|
46
46
|
<br>
|
|
47
47
|
<br>
|
|
48
48
|
<br>
|
|
49
|
+
<a href="https://neverinstall.com/spaces/devtools?utm_source=github&utm_medium=sponsor&utm_campaign=sindre#gh-light-mode-only">
|
|
50
|
+
<div>
|
|
51
|
+
<img src="https://sindresorhus.com/assets/thanks/neverinstall-logo-light.svg" width="200" alt="neverinstall">
|
|
52
|
+
</div>
|
|
53
|
+
<br>
|
|
54
|
+
<b>All your favourite IDE's now available on the cloud</b>
|
|
55
|
+
<div>
|
|
56
|
+
<sub>
|
|
57
|
+
Neverinstall gives you an uninterrupted development experience and improved accessibility,
|
|
58
|
+
<br>
|
|
59
|
+
allowing you to code faster, better and on-the-go on your favourite IDEs like
|
|
60
|
+
<br>
|
|
61
|
+
Android Studio, VS Code, Jupyter and PyCharm using your browser.
|
|
62
|
+
</sub>
|
|
63
|
+
</div>
|
|
64
|
+
</a>
|
|
65
|
+
<a href="https://neverinstall.com/spaces/devtools?utm_source=github&utm_medium=sponsor&utm_campaign=sindre#gh-dark-mode-only">
|
|
66
|
+
<div>
|
|
67
|
+
<img src="https://sindresorhus.com/assets/thanks/neverinstall-logo-dark.svg" width="200" alt="neverinstall">
|
|
68
|
+
</div>
|
|
69
|
+
<br>
|
|
70
|
+
<b>All your favourite IDE's now available on the cloud</b>
|
|
71
|
+
<div>
|
|
72
|
+
<sub>
|
|
73
|
+
Neverinstall gives you an uninterrupted development experience and improved accessibility,
|
|
74
|
+
<br>
|
|
75
|
+
allowing you to code faster, better and on-the-go on your favourite IDEs like
|
|
76
|
+
<br>
|
|
77
|
+
Android Studio, VS Code, Jupyter and PyCharm using your browser.
|
|
78
|
+
</sub>
|
|
79
|
+
</div>
|
|
80
|
+
</a>
|
|
81
|
+
<br>
|
|
82
|
+
<br>
|
|
83
|
+
<br>
|
|
84
|
+
<a href="https://www.useanvil.com/?utm_source=sindresorhus#gh-light-mode-only">
|
|
85
|
+
<div>
|
|
86
|
+
<img src="https://sindresorhus.com/assets/thanks/anvil-logo-light.svg" width="200" alt="Anvil">
|
|
87
|
+
</div>
|
|
88
|
+
<br>
|
|
89
|
+
<b>Paperwork that makes the data work.</b>
|
|
90
|
+
<div>
|
|
91
|
+
<sub>
|
|
92
|
+
Easy APIs for paperwork. PDF generation, e-signature and embeddable no-code webforms.
|
|
93
|
+
<br>
|
|
94
|
+
The easiest way to build paperwork automation into your product.
|
|
95
|
+
</sub>
|
|
96
|
+
</div>
|
|
97
|
+
</a>
|
|
98
|
+
<a href="https://www.useanvil.com/?utm_source=sindresorhus#gh-dark-mode-only">
|
|
99
|
+
<div>
|
|
100
|
+
<img src="https://sindresorhus.com/assets/thanks/anvil-logo-dark.svg" width="200" alt="Anvil">
|
|
101
|
+
</div>
|
|
102
|
+
<br>
|
|
103
|
+
<b>Paperwork that makes the data work.</b>
|
|
104
|
+
<div>
|
|
105
|
+
<sub>
|
|
106
|
+
Easy APIs for paperwork. PDF generation, e-signature and embeddable no-code webforms.
|
|
107
|
+
<br>
|
|
108
|
+
The easiest way to build paperwork automation into your product.
|
|
109
|
+
</sub>
|
|
110
|
+
</div>
|
|
111
|
+
</a>
|
|
112
|
+
<br>
|
|
113
|
+
<br>
|
|
114
|
+
<br>
|
|
49
115
|
<br>
|
|
50
116
|
</p>
|
|
51
117
|
<br>
|
|
@@ -74,7 +140,7 @@ For browser usage, we recommend [Ky](https://github.com/sindresorhus/ky) by the
|
|
|
74
140
|
npm install got
|
|
75
141
|
```
|
|
76
142
|
|
|
77
|
-
**Warning:** This package is native [ESM](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules) and no longer provides a CommonJS export. If your project uses CommonJS, you'll have to [convert to ESM](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c) or use the [dynamic `import()`](https://v8.dev/features/dynamic-import) function. Please don't open issues for questions regarding CommonJS / ESM. You can also use [Got v11](https://github.com/sindresorhus/got/tree/v11.8.3) instead which is pretty stable.
|
|
143
|
+
**Warning:** This package is native [ESM](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules) and no longer provides a CommonJS export. If your project uses CommonJS, you'll have to [convert to ESM](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c) or use the [dynamic `import()`](https://v8.dev/features/dynamic-import) function. Please don't open issues for questions regarding CommonJS / ESM. You can also use [Got v11](https://github.com/sindresorhus/got/tree/v11.8.3) instead which is pretty stable. We will backport security fixes to v11 for the foreseeable future.
|
|
78
144
|
|
|
79
145
|
## Take a peek
|
|
80
146
|
|
|
@@ -102,7 +168,7 @@ For advanced JSON usage, check out the [`parseJson`](documentation/2-options.md#
|
|
|
102
168
|
|
|
103
169
|
## Highlights
|
|
104
170
|
|
|
105
|
-
- [Used by
|
|
171
|
+
- [Used by 8K+ packages and 4M+ repos](https://github.com/sindresorhus/got/network/dependents)
|
|
106
172
|
- [Actively maintained](https://github.com/sindresorhus/got/graphs/contributors)
|
|
107
173
|
- [Trusted by many companies](#widely-used)
|
|
108
174
|
|
|
@@ -136,7 +202,7 @@ For advanced JSON usage, check out the [`parseJson`](documentation/2-options.md#
|
|
|
136
202
|
|
|
137
203
|
- [x] [RFC compliant caching](documentation/cache.md)
|
|
138
204
|
- [x] [Proxy support](documentation/tips.md#proxying)
|
|
139
|
-
- [x] [Unix Domain Sockets](documentation/
|
|
205
|
+
- [x] [Unix Domain Sockets](documentation/2-options.md#enableunixsockets)
|
|
140
206
|
|
|
141
207
|
#### Integration
|
|
142
208
|
|