got 14.6.6 → 15.0.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/as-promise/index.d.ts +2 -2
- package/dist/source/as-promise/index.js +59 -41
- package/dist/source/as-promise/types.d.ts +10 -23
- package/dist/source/as-promise/types.js +1 -17
- package/dist/source/core/calculate-retry-delay.js +1 -4
- package/dist/source/core/diagnostics-channel.js +12 -21
- package/dist/source/core/errors.d.ts +2 -1
- package/dist/source/core/errors.js +7 -10
- package/dist/source/core/index.d.ts +19 -7
- package/dist/source/core/index.js +725 -307
- package/dist/source/core/options.d.ts +92 -91
- package/dist/source/core/options.js +616 -303
- package/dist/source/core/response.d.ts +5 -3
- package/dist/source/core/response.js +26 -3
- package/dist/source/core/timed-out.d.ts +1 -1
- package/dist/source/core/timed-out.js +3 -3
- package/dist/source/core/utils/defer-to-connect.js +5 -17
- package/dist/source/core/utils/get-body-size.d.ts +1 -1
- package/dist/source/core/utils/get-body-size.js +3 -20
- package/dist/source/core/utils/proxy-events.d.ts +1 -1
- package/dist/source/core/utils/proxy-events.js +3 -3
- package/dist/source/core/utils/strip-url-auth.d.ts +1 -0
- package/dist/source/core/utils/strip-url-auth.js +9 -0
- package/dist/source/core/utils/timer.js +5 -7
- package/dist/source/core/utils/unhandle.js +1 -2
- package/dist/source/create.js +83 -27
- package/dist/source/index.d.ts +2 -3
- package/dist/source/index.js +0 -4
- package/dist/source/types.d.ts +40 -70
- package/package.json +34 -38
- package/readme.md +2 -2
- package/dist/source/core/utils/is-form-data.d.ts +0 -7
- package/dist/source/core/utils/is-form-data.js +0 -4
- package/dist/source/core/utils/url-to-options.d.ts +0 -14
- package/dist/source/core/utils/url-to-options.js +0 -22
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { Buffer } from 'node:buffer';
|
|
2
1
|
import { checkServerIdentity, type SecureContextOptions, type DetailedPeerCertificate } from 'node:tls';
|
|
3
2
|
import https, { type RequestOptions as HttpsRequestOptions, type Agent as HttpsAgent } from 'node:https';
|
|
4
3
|
import http, { type Agent as HttpAgent, type ClientRequest } from 'node:http';
|
|
@@ -6,16 +5,15 @@ import type { Readable } from 'node:stream';
|
|
|
6
5
|
import type { Socket, LookupFunction } from 'node:net';
|
|
7
6
|
import CacheableLookup from 'cacheable-lookup';
|
|
8
7
|
import http2wrapper, { type ClientHttp2Session } from 'http2-wrapper';
|
|
9
|
-
import { type FormDataLike } from 'form-data-encoder';
|
|
10
8
|
import type { KeyvStoreAdapter } from 'keyv';
|
|
11
9
|
import type KeyvType from 'keyv';
|
|
12
10
|
import type ResponseLike from 'responselike';
|
|
13
|
-
import type {
|
|
11
|
+
import type { RequestPromise } from '../as-promise/types.js';
|
|
14
12
|
import type { IncomingMessageWithTimings } from './utils/timer.js';
|
|
15
13
|
import type { PlainResponse, Response } from './response.js';
|
|
16
14
|
import type { RequestError } from './errors.js';
|
|
17
15
|
import type { Delays } from './timed-out.js';
|
|
18
|
-
type StorageAdapter = KeyvStoreAdapter | KeyvType | Map<
|
|
16
|
+
type StorageAdapter = KeyvStoreAdapter | KeyvType | Map<unknown, unknown>;
|
|
19
17
|
type Promisable<T> = T | Promise<T>;
|
|
20
18
|
export type DnsLookupIpVersion = undefined | 4 | 6;
|
|
21
19
|
type Except<ObjectType, KeysType extends keyof ObjectType> = Pick<ObjectType, Exclude<keyof ObjectType, KeysType>>;
|
|
@@ -23,7 +21,7 @@ export type NativeRequestOptions = HttpsRequestOptions & CacheOptions & {
|
|
|
23
21
|
checkServerIdentity?: CheckServerIdentityFunction;
|
|
24
22
|
};
|
|
25
23
|
type AcceptableResponse = IncomingMessageWithTimings | ResponseLike;
|
|
26
|
-
type AcceptableRequestResult = Promisable<AcceptableResponse | ClientRequest
|
|
24
|
+
type AcceptableRequestResult = Promisable<AcceptableResponse | ClientRequest | undefined>;
|
|
27
25
|
export type RequestFunction = (url: URL, options: NativeRequestOptions, callback?: (response: AcceptableResponse) => void) => AcceptableRequestResult;
|
|
28
26
|
export type Agents = {
|
|
29
27
|
http?: HttpAgent | false;
|
|
@@ -31,9 +29,20 @@ export type Agents = {
|
|
|
31
29
|
http2?: unknown | false;
|
|
32
30
|
};
|
|
33
31
|
export type Headers = Record<string, string | string[] | undefined>;
|
|
32
|
+
export type CrossOriginState = {
|
|
33
|
+
headers: Headers;
|
|
34
|
+
username: string;
|
|
35
|
+
password: string;
|
|
36
|
+
body: unknown;
|
|
37
|
+
json: unknown;
|
|
38
|
+
form: unknown;
|
|
39
|
+
bodySnapshot: unknown;
|
|
40
|
+
jsonSnapshot: unknown;
|
|
41
|
+
formSnapshot: unknown;
|
|
42
|
+
};
|
|
34
43
|
export type ToughCookieJar = {
|
|
35
|
-
getCookieString: ((currentUrl: string, options: Record<string, unknown>, callback: (error: Error |
|
|
36
|
-
setCookie: ((cookieOrString: unknown, currentUrl: string, options: Record<string, unknown>, callback: (error: Error |
|
|
44
|
+
getCookieString: ((currentUrl: string, options: Record<string, unknown>, callback: (error: Error | undefined, cookies: string) => void) => void) & ((url: string, callback: (error: Error | undefined, cookieHeader: string) => void) => void);
|
|
45
|
+
setCookie: ((cookieOrString: unknown, currentUrl: string, options: Record<string, unknown>, callback: (error: Error | undefined, cookie: unknown) => void) => void) & ((rawCookie: string, url: string, callback: (error: Error | undefined, result: unknown) => void) => void);
|
|
37
46
|
};
|
|
38
47
|
export type PromiseCookieJar = {
|
|
39
48
|
getCookieString: (url: string) => Promise<string>;
|
|
@@ -70,7 +79,7 @@ export type BeforeRedirectHook = (updatedOptions: NormalizedOptions, plainRespon
|
|
|
70
79
|
export type BeforeErrorHook = (error: RequestError) => Promisable<Error>;
|
|
71
80
|
export type BeforeRetryHook = (error: RequestError, retryCount: number) => Promisable<void>;
|
|
72
81
|
export type BeforeCacheHook = (response: PlainResponse) => false | void;
|
|
73
|
-
export type AfterResponseHook<ResponseType = unknown> = (response: Response<ResponseType>, retryWithMergedOptions: (options: OptionsInit) => never) => Promisable<Response |
|
|
82
|
+
export type AfterResponseHook<ResponseType = unknown> = (response: Response<ResponseType>, retryWithMergedOptions: (options: OptionsInit) => never) => Promisable<Response | RequestPromise<Response>>;
|
|
74
83
|
/**
|
|
75
84
|
All available hooks of Got.
|
|
76
85
|
*/
|
|
@@ -522,9 +531,9 @@ Delays between retries counts with function `1000 * Math.pow(2, retry) + Math.ra
|
|
|
522
531
|
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.
|
|
523
532
|
The function must return a delay in milliseconds (or a Promise resolving with it) (`0` return value cancels retry).
|
|
524
533
|
|
|
525
|
-
The `enforceRetryRules` property is a `boolean` that, when set to `true
|
|
534
|
+
The `enforceRetryRules` property is a `boolean` that, when set to `true` (default), enforces the `limit`, `methods`, `statusCodes`, and `errorCodes` options before calling `calculateDelay`. Your `calculateDelay` function is only invoked when a retry is allowed based on these criteria. When `false`, `calculateDelay` receives the computed value but can override all retry logic.
|
|
526
535
|
|
|
527
|
-
__Note:__ When `enforceRetryRules` is `false`, you must check `computedValue` in your `calculateDelay` function to respect
|
|
536
|
+
__Note:__ When `enforceRetryRules` is `false`, you must check `computedValue` in your `calculateDelay` function to respect retry rules. When `true` (default), the retry rules are enforced automatically.
|
|
528
537
|
|
|
529
538
|
By default, it retries *only* on the specified methods, status codes, and on these network errors:
|
|
530
539
|
- `ETIMEDOUT`: One of the [timeout](#timeout) limits were reached.
|
|
@@ -560,10 +569,10 @@ export type CacheOptions = {
|
|
|
560
569
|
ignoreCargoCult?: boolean;
|
|
561
570
|
};
|
|
562
571
|
type PfxObject = {
|
|
563
|
-
buffer: string |
|
|
572
|
+
buffer: string | Uint8Array;
|
|
564
573
|
passphrase?: string | undefined;
|
|
565
574
|
};
|
|
566
|
-
type PfxType = string |
|
|
575
|
+
type PfxType = string | Uint8Array | Array<string | Uint8Array | PfxObject> | undefined;
|
|
567
576
|
export type HttpsOptions = {
|
|
568
577
|
alpnProtocols?: string[];
|
|
569
578
|
rejectUnauthorized?: NativeRequestOptions['rejectUnauthorized'];
|
|
@@ -606,7 +615,7 @@ export type HttpsOptions = {
|
|
|
606
615
|
[PEM](https://en.wikipedia.org/wiki/Privacy-Enhanced_Mail) allows the option of private keys being encrypted.
|
|
607
616
|
Encrypted keys will be decrypted with `options.https.passphrase`.
|
|
608
617
|
|
|
609
|
-
Multiple keys with different passphrases can be provided as an array of `{pem: <string |
|
|
618
|
+
Multiple keys with different passphrases can be provided as an array of `{pem: <string | Uint8Array>, passphrase: <string>}`
|
|
610
619
|
*/
|
|
611
620
|
key?: SecureContextOptions['key'];
|
|
612
621
|
/**
|
|
@@ -767,26 +776,30 @@ export type PaginationOptions<ElementType, BodyType> = {
|
|
|
767
776
|
*/
|
|
768
777
|
stackAllItems?: boolean;
|
|
769
778
|
};
|
|
770
|
-
export type SearchParameters = Record<string, string | number | boolean |
|
|
779
|
+
export type SearchParameters = Record<string, string | number | boolean | undefined>;
|
|
780
|
+
export declare function isSameOrigin(previousUrl: URL, nextUrl: URL): boolean;
|
|
781
|
+
export declare const crossOriginStripHeaders: readonly ["host", "cookie", "cookie2", "authorization", "proxy-authorization"];
|
|
782
|
+
export declare const hasExplicitCredentialInUrlChange: (changedState: Set<string>, url: URL | undefined, credential: "username" | "password") => boolean;
|
|
783
|
+
export declare function applyUrlOverride(options: Options, url: string | URL, { username, password }?: {
|
|
784
|
+
username?: string;
|
|
785
|
+
password?: string;
|
|
786
|
+
}): URL;
|
|
771
787
|
/**
|
|
772
788
|
All parsing methods supported by Got.
|
|
773
789
|
*/
|
|
774
790
|
export type ResponseType = 'json' | 'buffer' | 'text';
|
|
775
|
-
type OptionsToSkip = 'searchParameters' | 'followRedirects' | 'auth' | 'toJSON' | 'merge' | '
|
|
791
|
+
type OptionsToSkip = 'searchParameters' | 'followRedirects' | 'auth' | 'toJSON' | 'merge' | 'isHeaderExplicitlySet' | 'shouldCopyPipedHeader' | 'setPipedHeader' | 'getInternalHeaders' | 'setInternalHeader' | 'deleteInternalHeader' | 'trackStateMutations' | 'clearBody' | 'stripUnchangedCrossOriginState' | 'stripSensitiveHeaders' | 'createNativeRequestOptions' | 'getRequestFunction' | 'freeze';
|
|
776
792
|
export type InternalsType = Except<Options, OptionsToSkip>;
|
|
777
793
|
export type OptionsError = NodeJS.ErrnoException & {
|
|
778
794
|
options?: Options;
|
|
779
795
|
};
|
|
780
|
-
export type OptionsInit = Except<Partial<InternalsType>, 'hooks' | 'retry'> & {
|
|
796
|
+
export type OptionsInit = Except<Partial<InternalsType>, 'hooks' | 'retry' | 'isStream'> & {
|
|
781
797
|
hooks?: Partial<Hooks>;
|
|
782
798
|
retry?: Partial<RetryOptions>;
|
|
783
799
|
preserveHooks?: boolean;
|
|
784
800
|
};
|
|
785
801
|
export default class Options {
|
|
786
|
-
private
|
|
787
|
-
private readonly _internals;
|
|
788
|
-
private _merging;
|
|
789
|
-
private readonly _init;
|
|
802
|
+
#private;
|
|
790
803
|
constructor(input?: string | URL | OptionsInit, options?: OptionsInit, defaults?: Options);
|
|
791
804
|
merge(options?: OptionsInit | Options): void;
|
|
792
805
|
/**
|
|
@@ -828,7 +841,7 @@ export default class Options {
|
|
|
828
841
|
|
|
829
842
|
This will set the `accept-encoding` header to `gzip, deflate, br` unless you set it yourself.
|
|
830
843
|
|
|
831
|
-
If this is disabled, a compressed response is returned as a `
|
|
844
|
+
If this is disabled, a compressed response is returned as a `Uint8Array`.
|
|
832
845
|
This may be useful if you want to handle decompression yourself or stream the raw compressed data.
|
|
833
846
|
|
|
834
847
|
@default true
|
|
@@ -902,7 +915,7 @@ export default class Options {
|
|
|
902
915
|
|
|
903
916
|
__Note #4__: This option is not enumerable and will not be merged with the instance defaults.
|
|
904
917
|
|
|
905
|
-
The `content-length` header will be automatically set if `body` is a `string` / `
|
|
918
|
+
The `content-length` header will be automatically set if `body` is a `string` / `Uint8Array` / typed array, and `content-length` and `transfer-encoding` are not manually set in `options.headers`.
|
|
906
919
|
|
|
907
920
|
Since Got 12, the `content-length` is not automatically set when `body` is a `fs.createReadStream`.
|
|
908
921
|
|
|
@@ -923,8 +936,8 @@ export default class Options {
|
|
|
923
936
|
});
|
|
924
937
|
```
|
|
925
938
|
*/
|
|
926
|
-
get body(): string |
|
|
927
|
-
set body(value: string |
|
|
939
|
+
get body(): string | Uint8Array | Readable | Generator | AsyncGenerator | Iterable<unknown> | AsyncIterable<unknown> | FormData | ArrayBufferView | undefined;
|
|
940
|
+
set body(value: string | Uint8Array | Readable | Generator | AsyncGenerator | Iterable<unknown> | AsyncIterable<unknown> | FormData | ArrayBufferView | undefined);
|
|
928
941
|
/**
|
|
929
942
|
The form body is converted to a query string using [`(new URLSearchParams(object)).toString()`](https://nodejs.org/api/url.html#url_constructor_new_urlsearchparams_obj).
|
|
930
943
|
|
|
@@ -1084,6 +1097,7 @@ export default class Options {
|
|
|
1084
1097
|
|
|
1085
1098
|
Note that if a `303` is sent by the server in response to any request type (`POST`, `DELETE`, etc.), Got will automatically request the resource pointed to in the location header via `GET`.
|
|
1086
1099
|
This is in accordance with [the spec](https://tools.ietf.org/html/rfc7231#section-6.4.4). You can optionally turn on this behavior also for other redirect codes - see `methodRewriting`.
|
|
1100
|
+
On cross-origin redirects, Got strips `host`, `cookie`, `cookie2`, `authorization`, and `proxy-authorization`. When a redirect rewrites the request to `GET`, Got also strips request body headers. Use `hooks.beforeRedirect` for app-specific sensitive headers.
|
|
1087
1101
|
|
|
1088
1102
|
@default true
|
|
1089
1103
|
*/
|
|
@@ -1158,25 +1172,24 @@ export default class Options {
|
|
|
1158
1172
|
|
|
1159
1173
|
When piping a request into a Got stream (e.g., `request.pipe(got.stream(url))`), this controls whether headers from the source stream are automatically merged into the Got request headers.
|
|
1160
1174
|
|
|
1161
|
-
Note:
|
|
1175
|
+
Note: Explicitly set headers take precedence over piped headers. Piped headers are only copied when a header is not already explicitly set.
|
|
1162
1176
|
|
|
1163
|
-
Useful for proxy scenarios, but you may want to
|
|
1177
|
+
Useful for proxy scenarios when explicitly enabled, but you may still want to filter out headers like `Host`, `Connection`, `Authorization`, etc.
|
|
1164
1178
|
|
|
1165
|
-
@default
|
|
1179
|
+
@default false
|
|
1166
1180
|
|
|
1167
1181
|
@example
|
|
1168
1182
|
```
|
|
1169
1183
|
import got from 'got';
|
|
1170
1184
|
import {pipeline} from 'node:stream/promises';
|
|
1171
1185
|
|
|
1172
|
-
//
|
|
1186
|
+
// Opt in to automatic header copying for proxy scenarios
|
|
1173
1187
|
server.get('/proxy', async (request, response) => {
|
|
1174
1188
|
const gotStream = got.stream('https://example.com', {
|
|
1175
|
-
copyPipedHeaders:
|
|
1189
|
+
copyPipedHeaders: true,
|
|
1190
|
+
// Explicit headers win over piped headers
|
|
1176
1191
|
headers: {
|
|
1177
|
-
|
|
1178
|
-
'accept': request.headers['accept'],
|
|
1179
|
-
// Explicitly NOT copying host, connection, authorization, etc.
|
|
1192
|
+
host: 'example.com',
|
|
1180
1193
|
}
|
|
1181
1194
|
});
|
|
1182
1195
|
|
|
@@ -1187,23 +1200,40 @@ export default class Options {
|
|
|
1187
1200
|
@example
|
|
1188
1201
|
```
|
|
1189
1202
|
import got from 'got';
|
|
1203
|
+
import {pipeline} from 'node:stream/promises';
|
|
1190
1204
|
|
|
1191
|
-
//
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1205
|
+
// Keep it disabled and manually copy only safe headers
|
|
1206
|
+
server.get('/proxy', async (request, response) => {
|
|
1207
|
+
const gotStream = got.stream('https://example.com', {
|
|
1208
|
+
headers: {
|
|
1209
|
+
'user-agent': request.headers['user-agent'],
|
|
1210
|
+
'accept': request.headers['accept'],
|
|
1211
|
+
// Explicitly NOT copying host, connection, authorization, etc.
|
|
1212
|
+
}
|
|
1213
|
+
});
|
|
1214
|
+
|
|
1215
|
+
await pipeline(request, gotStream, response);
|
|
1202
1216
|
});
|
|
1203
1217
|
```
|
|
1204
1218
|
*/
|
|
1205
1219
|
get copyPipedHeaders(): boolean;
|
|
1206
1220
|
set copyPipedHeaders(value: boolean);
|
|
1221
|
+
isHeaderExplicitlySet(name: string): boolean;
|
|
1222
|
+
shouldCopyPipedHeader(name: string): boolean;
|
|
1223
|
+
setPipedHeader(name: string, value: string | string[] | undefined): void;
|
|
1224
|
+
getInternalHeaders(): Headers;
|
|
1225
|
+
setInternalHeader(name: string, value: string | string[] | undefined): void;
|
|
1226
|
+
deleteInternalHeader(name: string): void;
|
|
1227
|
+
trackStateMutations<Value>(operation: (changedState: Set<string>) => Promisable<Value>): Promise<Value>;
|
|
1228
|
+
clearBody(): void;
|
|
1229
|
+
stripUnchangedCrossOriginState(previousState: CrossOriginState, changedState: Set<string>, { clearBody }?: {
|
|
1230
|
+
clearBody?: boolean;
|
|
1231
|
+
}): void;
|
|
1232
|
+
/**
|
|
1233
|
+
Strip sensitive headers and credentials when navigating to a different origin.
|
|
1234
|
+
Headers and credentials explicitly provided in `userOptions` are preserved.
|
|
1235
|
+
*/
|
|
1236
|
+
stripSensitiveHeaders(previousUrl: URL, nextUrl: URL, userOptions: OptionsInit): void;
|
|
1207
1237
|
/**
|
|
1208
1238
|
Request headers.
|
|
1209
1239
|
|
|
@@ -1216,8 +1246,8 @@ export default class Options {
|
|
|
1216
1246
|
/**
|
|
1217
1247
|
Specifies if the HTTP request method should be [rewritten as `GET`](https://tools.ietf.org/html/rfc7231#section-6.4) on redirects.
|
|
1218
1248
|
|
|
1219
|
-
As the [specification](https://tools.ietf.org/html/rfc7231#section-6.4) prefers to rewrite the HTTP method only on `303` responses, this is Got's default behavior.
|
|
1220
|
-
Setting `methodRewriting` to `true` will also rewrite `301` and `302` responses, as allowed by the spec. This is the behavior followed by `curl` and browsers.
|
|
1249
|
+
As the [specification](https://tools.ietf.org/html/rfc7231#section-6.4) prefers to rewrite the HTTP method only on `303` responses, this is Got's default behavior. Cross-origin `301` and `302` redirects also rewrite `POST` requests to `GET` by default to avoid forwarding request bodies to another origin.
|
|
1250
|
+
Setting `methodRewriting` to `true` will also rewrite same-origin `301` and `302` responses, as allowed by the spec. This is the behavior followed by `curl` and browsers.
|
|
1221
1251
|
|
|
1222
1252
|
__Note__: Got never performs method rewriting on `307` and `308` responses, as this is [explicitly prohibited by the specification](https://www.rfc-editor.org/rfc/rfc7231#section-6.4.7).
|
|
1223
1253
|
|
|
@@ -1305,9 +1335,9 @@ export default class Options {
|
|
|
1305
1335
|
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.
|
|
1306
1336
|
The function must return a delay in milliseconds (or a Promise resolving with it) (`0` return value cancels retry).
|
|
1307
1337
|
|
|
1308
|
-
The `enforceRetryRules` property is a `boolean` that, when set to `true
|
|
1338
|
+
The `enforceRetryRules` property is a `boolean` that, when set to `true` (default), enforces the `limit`, `methods`, `statusCodes`, and `errorCodes` options before calling `calculateDelay`. Your `calculateDelay` function is only invoked when a retry is allowed based on these criteria. When `false`, `calculateDelay` receives the computed value but can override all retry logic.
|
|
1309
1339
|
|
|
1310
|
-
__Note:__ When `enforceRetryRules` is `false`, you must check `computedValue` in your `calculateDelay` function to respect
|
|
1340
|
+
__Note:__ When `enforceRetryRules` is `false`, you must check `computedValue` in your `calculateDelay` function to respect retry rules. When `true` (default), the retry rules are enforced automatically.
|
|
1311
1341
|
|
|
1312
1342
|
By default, it retries *only* on the specified methods, status codes, and on these network errors:
|
|
1313
1343
|
|
|
@@ -1356,7 +1386,7 @@ export default class Options {
|
|
|
1356
1386
|
/**
|
|
1357
1387
|
[Encoding](https://nodejs.org/api/buffer.html#buffer_buffers_and_character_encodings) to be used on `setEncoding` of the response data.
|
|
1358
1388
|
|
|
1359
|
-
To get a [`
|
|
1389
|
+
To get a [`Uint8Array`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array), you need to set `responseType` to `buffer` instead.
|
|
1360
1390
|
Don't set this option to `null`.
|
|
1361
1391
|
|
|
1362
1392
|
__Note__: This doesn't affect streams! Instead, you need to do `got.stream(...).setEncoding(encoding)`.
|
|
@@ -1372,13 +1402,6 @@ export default class Options {
|
|
|
1372
1402
|
*/
|
|
1373
1403
|
get resolveBodyOnly(): boolean;
|
|
1374
1404
|
set resolveBodyOnly(value: boolean);
|
|
1375
|
-
/**
|
|
1376
|
-
Returns a `Stream` instead of a `Promise`.
|
|
1377
|
-
This is equivalent to calling `got.stream(url, options?)`.
|
|
1378
|
-
|
|
1379
|
-
@default false
|
|
1380
|
-
*/
|
|
1381
|
-
get isStream(): boolean;
|
|
1382
1405
|
set isStream(value: boolean);
|
|
1383
1406
|
/**
|
|
1384
1407
|
The parsing method.
|
|
@@ -1397,7 +1420,7 @@ export default class Options {
|
|
|
1397
1420
|
|
|
1398
1421
|
const [response, buffer, json] = Promise.all([responsePromise, bufferPromise, jsonPromise]);
|
|
1399
1422
|
// `response` is an instance of Got Response
|
|
1400
|
-
// `buffer` is an instance of
|
|
1423
|
+
// `buffer` is an instance of Uint8Array
|
|
1401
1424
|
// `json` is an object
|
|
1402
1425
|
```
|
|
1403
1426
|
|
|
@@ -1430,7 +1453,7 @@ export default class Options {
|
|
|
1430
1453
|
__Note__: Responses without a `content-length` header are not validated.
|
|
1431
1454
|
__Note__: When enabled and validation fails, a `ReadError` with code `ERR_HTTP_CONTENT_LENGTH_MISMATCH` will be thrown.
|
|
1432
1455
|
|
|
1433
|
-
@default
|
|
1456
|
+
@default true
|
|
1434
1457
|
*/
|
|
1435
1458
|
get strictContentLength(): boolean;
|
|
1436
1459
|
set strictContentLength(value: boolean);
|
|
@@ -1438,18 +1461,16 @@ export default class Options {
|
|
|
1438
1461
|
timeout: Delays;
|
|
1439
1462
|
headers: Headers;
|
|
1440
1463
|
request: RequestFunction | undefined;
|
|
1441
|
-
username: string;
|
|
1442
|
-
password: string;
|
|
1443
1464
|
json: unknown;
|
|
1444
1465
|
followRedirect: boolean | ((response: PlainResponse) => boolean);
|
|
1466
|
+
body: string | Uint8Array | Readable | Generator | AsyncGenerator | Iterable<unknown> | AsyncIterable<unknown> | FormData | ArrayBufferView | undefined;
|
|
1467
|
+
url: string | URL | undefined;
|
|
1445
1468
|
retry: Partial<RetryOptions>;
|
|
1446
1469
|
agent: Agents;
|
|
1447
1470
|
h2session: ClientHttp2Session | undefined;
|
|
1448
1471
|
decompress: boolean;
|
|
1449
1472
|
prefixUrl: string | URL;
|
|
1450
|
-
body: string | Buffer | Readable | Generator | AsyncGenerator | Iterable<unknown> | AsyncIterable<unknown> | FormDataLike | ArrayBufferView | undefined;
|
|
1451
1473
|
form: Record<string, any> | undefined;
|
|
1452
|
-
url: string | URL | undefined;
|
|
1453
1474
|
cookieJar: PromiseCookieJar | ToughCookieJar | undefined;
|
|
1454
1475
|
signal: AbortSignal | undefined;
|
|
1455
1476
|
ignoreInvalidCookies: boolean;
|
|
@@ -1461,6 +1482,8 @@ export default class Options {
|
|
|
1461
1482
|
maxRedirects: number;
|
|
1462
1483
|
cache: string | StorageAdapter | boolean | undefined;
|
|
1463
1484
|
throwHttpErrors: boolean;
|
|
1485
|
+
username: string;
|
|
1486
|
+
password: string;
|
|
1464
1487
|
http2: boolean;
|
|
1465
1488
|
allowGetBody: boolean;
|
|
1466
1489
|
copyPipedHeaders: boolean;
|
|
@@ -1487,7 +1510,7 @@ export default class Options {
|
|
|
1487
1510
|
ALPNProtocols: string[] | undefined;
|
|
1488
1511
|
ca: string | Buffer<ArrayBufferLike> | (string | Buffer<ArrayBufferLike>)[] | undefined;
|
|
1489
1512
|
cert: string | Buffer<ArrayBufferLike> | (string | Buffer<ArrayBufferLike>)[] | undefined;
|
|
1490
|
-
key: string | Buffer<ArrayBufferLike> | (string | Buffer<ArrayBufferLike> | import("tls").KeyObject)[] | undefined;
|
|
1513
|
+
key: string | Buffer<ArrayBufferLike> | (string | Buffer<ArrayBufferLike> | import("node:tls").KeyObject)[] | undefined;
|
|
1491
1514
|
passphrase: string | undefined;
|
|
1492
1515
|
pfx: PfxType;
|
|
1493
1516
|
rejectUnauthorized: boolean | undefined;
|
|
@@ -1495,8 +1518,8 @@ export default class Options {
|
|
|
1495
1518
|
servername: string | undefined;
|
|
1496
1519
|
ciphers: string | undefined;
|
|
1497
1520
|
honorCipherOrder: boolean | undefined;
|
|
1498
|
-
minVersion: import("tls").SecureVersion | undefined;
|
|
1499
|
-
maxVersion: import("tls").SecureVersion | undefined;
|
|
1521
|
+
minVersion: import("node:tls").SecureVersion | undefined;
|
|
1522
|
+
maxVersion: import("node:tls").SecureVersion | undefined;
|
|
1500
1523
|
sigalgs: string | undefined;
|
|
1501
1524
|
sessionTimeout: number | undefined;
|
|
1502
1525
|
dhparam: string | Buffer<ArrayBufferLike> | undefined;
|
|
@@ -1525,40 +1548,18 @@ export default class Options {
|
|
|
1525
1548
|
createConnection: CreateConnectionFunction | undefined;
|
|
1526
1549
|
timeout: number | undefined;
|
|
1527
1550
|
h2session: http2wrapper.ClientHttp2Session | undefined;
|
|
1528
|
-
_defaultAgent?: http.Agent | undefined;
|
|
1529
|
-
auth?: string | null | undefined;
|
|
1530
|
-
defaultPort?: number | string | undefined;
|
|
1531
|
-
host?: string | null | undefined;
|
|
1532
|
-
hostname?: string | null | undefined;
|
|
1533
|
-
insecureHTTPParser?: boolean | undefined;
|
|
1534
|
-
localPort?: number | undefined;
|
|
1535
|
-
path?: string | null | undefined;
|
|
1536
|
-
port?: number | string | null | undefined;
|
|
1537
|
-
protocol?: string | null | undefined;
|
|
1538
|
-
setDefaultHeaders?: boolean | undefined;
|
|
1539
|
-
signal?: AbortSignal | undefined;
|
|
1540
1551
|
socketPath?: string | undefined;
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
hints?: number | undefined;
|
|
1544
|
-
ALPNCallback?: ((arg: {
|
|
1545
|
-
servername: string;
|
|
1546
|
-
protocols: string[];
|
|
1547
|
-
}) => string | undefined) | undefined;
|
|
1548
|
-
allowPartialTrustChain?: boolean | undefined;
|
|
1549
|
-
clientCertEngine?: string | undefined;
|
|
1550
|
-
privateKeyEngine?: string | undefined;
|
|
1551
|
-
privateKeyIdentifier?: string | undefined;
|
|
1552
|
-
secureProtocol?: string | undefined;
|
|
1553
|
-
sessionIdContext?: string | undefined;
|
|
1554
|
-
ticketKeys?: Buffer | undefined;
|
|
1552
|
+
path?: string | undefined;
|
|
1553
|
+
host?: string | undefined;
|
|
1555
1554
|
shared?: boolean;
|
|
1556
1555
|
cacheHeuristic?: number;
|
|
1557
1556
|
immutableMinTimeToLive?: number;
|
|
1558
1557
|
ignoreCargoCult?: boolean;
|
|
1559
1558
|
};
|
|
1560
1559
|
getRequestFunction(): RequestFunction | typeof https.request | undefined;
|
|
1561
|
-
getFallbackRequestFunction(): RequestFunction | typeof https.request | undefined;
|
|
1562
1560
|
freeze(): void;
|
|
1563
1561
|
}
|
|
1562
|
+
export declare const snapshotCrossOriginState: (options: Options) => CrossOriginState;
|
|
1563
|
+
export declare const isCrossOriginCredentialChanged: (previousUrl: URL, nextUrl: URL, credential: "username" | "password") => boolean;
|
|
1564
|
+
export declare const isBodyUnchanged: (options: Options, previousState: CrossOriginState) => boolean;
|
|
1564
1565
|
export {};
|