1 | /// <reference types="node" />
|
2 | import { Buffer } from 'node:buffer';
|
3 | import { URL, URLSearchParams } from 'node:url';
|
4 | import { checkServerIdentity } from 'node:tls';
|
5 | import http from 'node:http';
|
6 | import https from 'node:https';
|
7 | import type { Readable } from 'node:stream';
|
8 | import type { Socket } from 'node:net';
|
9 | import type { SecureContextOptions, DetailedPeerCertificate } from 'node:tls';
|
10 | import type { Agent as HttpAgent, ClientRequest } from 'node:http';
|
11 | import type { RequestOptions as HttpsRequestOptions, Agent as HttpsAgent } from 'node:https';
|
12 | import CacheableLookup from 'cacheable-lookup';
|
13 | import http2wrapper, { ClientHttp2Session } from 'http2-wrapper';
|
14 | import type { FormDataLike } from 'form-data-encoder';
|
15 | import type CacheableRequest from 'cacheable-request';
|
16 | import type ResponseLike from 'responselike';
|
17 | import type { IncomingMessageWithTimings } from '@szmarczak/http-timer';
|
18 | import type { CancelableRequest } from '../as-promise/types.js';
|
19 | import type { PlainResponse, Response } from './response.js';
|
20 | import type { RequestError } from './errors.js';
|
21 | import type { Delays } from './timed-out.js';
|
22 | declare type Promisable<T> = T | Promise<T>;
|
23 | export declare type DnsLookupIpVersion = undefined | 4 | 6;
|
24 | declare type Except<ObjectType, KeysType extends keyof ObjectType> = Pick<ObjectType, Exclude<keyof ObjectType, KeysType>>;
|
25 | export declare type NativeRequestOptions = HttpsRequestOptions & CacheOptions & {
|
26 | checkServerIdentity?: CheckServerIdentityFunction;
|
27 | };
|
28 | declare type AcceptableResponse = IncomingMessageWithTimings | ResponseLike;
|
29 | declare type AcceptableRequestResult = Promisable<AcceptableResponse | ClientRequest> | undefined;
|
30 | export declare type RequestFunction = (url: URL, options: NativeRequestOptions, callback?: (response: AcceptableResponse) => void) => AcceptableRequestResult;
|
31 | export interface Agents {
|
32 | http?: HttpAgent | false;
|
33 | https?: HttpsAgent | false;
|
34 | http2?: unknown | false;
|
35 | }
|
36 | export declare type Headers = Record<string, string | string[] | undefined>;
|
37 | export interface ToughCookieJar {
|
38 | getCookieString: ((currentUrl: string, options: Record<string, unknown>, cb: (error: Error | null, cookies: string) => void) => void) & ((url: string, callback: (error: Error | null, cookieHeader: string) => void) => void);
|
39 | setCookie: ((cookieOrString: unknown, currentUrl: string, options: Record<string, unknown>, cb: (error: Error | null, cookie: unknown) => void) => void) & ((rawCookie: string, url: string, callback: (error: Error | null, result: unknown) => void) => void);
|
40 | }
|
41 | export interface PromiseCookieJar {
|
42 | getCookieString: (url: string) => Promise<string>;
|
43 | setCookie: (rawCookie: string, url: string) => Promise<unknown>;
|
44 | }
|
45 | export declare type InitHook = (init: OptionsInit, self: Options) => void;
|
46 | export declare type BeforeRequestHook = (options: Options) => Promisable<void | Response | ResponseLike>;
|
47 | export declare type BeforeRedirectHook = (updatedOptions: Options, plainResponse: PlainResponse) => Promisable<void>;
|
48 | export declare type BeforeErrorHook = (error: RequestError) => Promisable<RequestError>;
|
49 | export declare type BeforeRetryHook = (error: RequestError, retryCount: number) => Promisable<void>;
|
50 | export declare type AfterResponseHook<ResponseType = unknown> = (response: Response<ResponseType>, retryWithMergedOptions: (options: OptionsInit) => never) => Promisable<Response | CancelableRequest<Response>>;
|
51 | /**
|
52 | All available hooks of Got.
|
53 | */
|
54 | export interface Hooks {
|
55 | /**
|
56 | Called with the plain request options, right before their normalization.
|
57 |
|
58 | The second argument represents the current `Options` instance.
|
59 |
|
60 | @default []
|
61 |
|
62 | **Note:**
|
63 | > - This hook must be synchronous.
|
64 |
|
65 | **Note:**
|
66 | > - This is called every time options are merged.
|
67 |
|
68 | **Note:**
|
69 | > - The `options` object may not have the `url` property. To modify it, use a `beforeRequest` hook instead.
|
70 |
|
71 | **Note:**
|
72 | > - This hook is called when a new instance of `Options` is created.
|
73 | > - Do not confuse this with the creation of `Request` or `got(…)`.
|
74 |
|
75 | **Note:**
|
76 | > - When using `got(url)` or `got(url, undefined, defaults)` this hook will **not** be called.
|
77 |
|
78 | This is especially useful in conjunction with `got.extend()` when the input needs custom handling.
|
79 |
|
80 | For example, this can be used to fix typos to migrate from older versions faster.
|
81 |
|
82 | @example
|
83 | ```
|
84 | import got from 'got';
|
85 |
|
86 | const instance = got.extend({
|
87 | hooks: {
|
88 | init: [
|
89 | plain => {
|
90 | if ('followRedirects' in plain) {
|
91 | plain.followRedirect = plain.followRedirects;
|
92 | delete plain.followRedirects;
|
93 | }
|
94 | }
|
95 | ]
|
96 | }
|
97 | });
|
98 |
|
99 | // Normally, the following would throw:
|
100 | const response = await instance(
|
101 | 'https://example.com',
|
102 | {
|
103 | followRedirects: true
|
104 | }
|
105 | );
|
106 |
|
107 | // There is no option named `followRedirects`, but we correct it in an `init` hook.
|
108 | ```
|
109 |
|
110 | Or you can create your own option and store it in a context:
|
111 |
|
112 | ```
|
113 | import got from 'got';
|
114 |
|
115 | const instance = got.extend({
|
116 | hooks: {
|
117 | init: [
|
118 | (plain, options) => {
|
119 | if ('secret' in plain) {
|
120 | options.context.secret = plain.secret;
|
121 | delete plain.secret;
|
122 | }
|
123 | }
|
124 | ],
|
125 | beforeRequest: [
|
126 | options => {
|
127 | options.headers.secret = options.context.secret;
|
128 | }
|
129 | ]
|
130 | }
|
131 | });
|
132 |
|
133 | const {headers} = await instance(
|
134 | 'https://httpbin.org/anything',
|
135 | {
|
136 | secret: 'passphrase'
|
137 | }
|
138 | ).json();
|
139 |
|
140 | console.log(headers.Secret);
|
141 | //=> 'passphrase'
|
142 | ```
|
143 | */
|
144 | init: InitHook[];
|
145 | /**
|
146 | Called right before making the request with `options.createNativeRequestOptions()`.
|
147 |
|
148 | This hook is especially useful in conjunction with `got.extend()` when you want to sign your request.
|
149 |
|
150 | @default []
|
151 |
|
152 | **Note:**
|
153 | > - Got will make no further changes to the request before it is sent.
|
154 |
|
155 | **Note:**
|
156 | > - Changing `options.json` or `options.form` has no effect on the request. You should change `options.body` instead. If needed, update the `options.headers` accordingly.
|
157 |
|
158 | @example
|
159 | ```
|
160 | import got from 'got';
|
161 |
|
162 | const response = await got.post(
|
163 | 'https://httpbin.org/anything',
|
164 | {
|
165 | json: {payload: 'old'},
|
166 | hooks: {
|
167 | beforeRequest: [
|
168 | options => {
|
169 | options.body = JSON.stringify({payload: 'new'});
|
170 | options.headers['content-length'] = options.body.length.toString();
|
171 | }
|
172 | ]
|
173 | }
|
174 | }
|
175 | );
|
176 | ```
|
177 |
|
178 | **Tip:**
|
179 | > - You can indirectly override the `request` function by early returning a [`ClientRequest`-like](https://nodejs.org/api/http.html#http_class_http_clientrequest) instance or a [`IncomingMessage`-like](https://nodejs.org/api/http.html#http_class_http_incomingmessage) instance. This is very useful when creating a custom cache mechanism.
|
180 | > - [Read more about this tip](https://github.com/sindresorhus/got/blob/main/documentation/cache.md#advanced-caching-mechanisms).
|
181 | */
|
182 | beforeRequest: BeforeRequestHook[];
|
183 | /**
|
184 | The equivalent of `beforeRequest` but when redirecting.
|
185 |
|
186 | @default []
|
187 |
|
188 | **Tip:**
|
189 | > - This is especially useful when you want to avoid dead sites.
|
190 |
|
191 | @example
|
192 | ```
|
193 | import got from 'got';
|
194 |
|
195 | const response = await got('https://example.com', {
|
196 | hooks: {
|
197 | beforeRedirect: [
|
198 | (options, response) => {
|
199 | if (options.hostname === 'deadSite') {
|
200 | options.hostname = 'fallbackSite';
|
201 | }
|
202 | }
|
203 | ]
|
204 | }
|
205 | });
|
206 | ```
|
207 | */
|
208 | beforeRedirect: BeforeRedirectHook[];
|
209 | /**
|
210 | Called with a `RequestError` instance. The error is passed to the hook right before it's thrown.
|
211 |
|
212 | This is especially useful when you want to have more detailed errors.
|
213 |
|
214 | @default []
|
215 |
|
216 | ```
|
217 | import got from 'got';
|
218 |
|
219 | await got('https://api.github.com/repos/sindresorhus/got/commits', {
|
220 | responseType: 'json',
|
221 | hooks: {
|
222 | beforeError: [
|
223 | error => {
|
224 | const {response} = error;
|
225 | if (response && response.body) {
|
226 | error.name = 'GitHubError';
|
227 | error.message = `${response.body.message} (${response.statusCode})`;
|
228 | }
|
229 |
|
230 | return error;
|
231 | }
|
232 | ]
|
233 | }
|
234 | });
|
235 | ```
|
236 | */
|
237 | beforeError: BeforeErrorHook[];
|
238 | /**
|
239 | The equivalent of `beforeError` but when retrying. Additionally, there is a second argument `retryCount`, the current retry number.
|
240 |
|
241 | @default []
|
242 |
|
243 | **Note:**
|
244 | > - When using the Stream API, this hook is ignored.
|
245 |
|
246 | **Note:**
|
247 | > - When retrying, the `beforeRequest` hook is called afterwards.
|
248 |
|
249 | **Note:**
|
250 | > - If no retry occurs, the `beforeError` hook is called instead.
|
251 |
|
252 | This hook is especially useful when you want to retrieve the cause of a retry.
|
253 |
|
254 | @example
|
255 | ```
|
256 | import got from 'got';
|
257 |
|
258 | await got('https://httpbin.org/status/500', {
|
259 | hooks: {
|
260 | beforeRetry: [
|
261 | (error, retryCount) => {
|
262 | console.log(`Retrying [${retryCount}]: ${error.code}`);
|
263 | // Retrying [1]: ERR_NON_2XX_3XX_RESPONSE
|
264 | }
|
265 | ]
|
266 | }
|
267 | });
|
268 | ```
|
269 | */
|
270 | beforeRetry: BeforeRetryHook[];
|
271 | /**
|
272 | Each function should return the response. This is especially useful when you want to refresh an access token.
|
273 |
|
274 | @default []
|
275 |
|
276 | **Note:**
|
277 | > - When using the Stream API, this hook is ignored.
|
278 |
|
279 | **Note:**
|
280 | > - Calling the `retryWithMergedOptions` function will trigger `beforeRetry` hooks. If the retry is successful, all remaining `afterResponse` hooks will be called. In case of an error, `beforeRetry` hooks will be called instead.
|
281 | Meanwhile the `init`, `beforeRequest` , `beforeRedirect` as well as already executed `afterResponse` hooks will be skipped.
|
282 |
|
283 | @example
|
284 | ```
|
285 | import got from 'got';
|
286 |
|
287 | const instance = got.extend({
|
288 | hooks: {
|
289 | afterResponse: [
|
290 | (response, retryWithMergedOptions) => {
|
291 | // Unauthorized
|
292 | if (response.statusCode === 401) {
|
293 | // Refresh the access token
|
294 | const updatedOptions = {
|
295 | headers: {
|
296 | token: getNewToken()
|
297 | }
|
298 | };
|
299 |
|
300 | // Update the defaults
|
301 | instance.defaults.options.merge(updatedOptions);
|
302 |
|
303 | // Make a new retry
|
304 | return retryWithMergedOptions(updatedOptions);
|
305 | }
|
306 |
|
307 | // No changes otherwise
|
308 | return response;
|
309 | }
|
310 | ],
|
311 | beforeRetry: [
|
312 | error => {
|
313 | // This will be called on `retryWithMergedOptions(...)`
|
314 | }
|
315 | ]
|
316 | },
|
317 | mutableDefaults: true
|
318 | });
|
319 | ```
|
320 | */
|
321 | afterResponse: AfterResponseHook[];
|
322 | }
|
323 | export declare type ParseJsonFunction = (text: string) => unknown;
|
324 | export declare type StringifyJsonFunction = (object: unknown) => string;
|
325 | /**
|
326 | All available HTTP request methods provided by Got.
|
327 | */
|
328 | export declare type Method = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'HEAD' | 'DELETE' | 'OPTIONS' | 'TRACE' | 'get' | 'post' | 'put' | 'patch' | 'head' | 'delete' | 'options' | 'trace';
|
329 | export interface RetryObject {
|
330 | attemptCount: number;
|
331 | retryOptions: RetryOptions;
|
332 | error: RequestError;
|
333 | computedValue: number;
|
334 | retryAfter?: number;
|
335 | }
|
336 | export declare type RetryFunction = (retryObject: RetryObject) => Promisable<number>;
|
337 | /**
|
338 | An object representing `limit`, `calculateDelay`, `methods`, `statusCodes`, `maxRetryAfter` and `errorCodes` fields for maximum retry count, retry handler, allowed methods, allowed status codes, maximum [`Retry-After`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After) time and allowed error codes.
|
339 |
|
340 | Delays between retries counts with function `1000 * Math.pow(2, retry) + Math.random() * 100`, where `retry` is attempt number (starts from 1).
|
341 |
|
342 | 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.
|
343 | The function must return a delay in milliseconds (or a Promise resolving with it) (`0` return value cancels retry).
|
344 |
|
345 | By default, it retries *only* on the specified methods, status codes, and on these network errors:
|
346 | - `ETIMEDOUT`: One of the [timeout](#timeout) limits were reached.
|
347 | - `ECONNRESET`: Connection was forcibly closed by a peer.
|
348 | - `EADDRINUSE`: Could not bind to any free port.
|
349 | - `ECONNREFUSED`: Connection was refused by the server.
|
350 | - `EPIPE`: The remote side of the stream being written has been closed.
|
351 | - `ENOTFOUND`: Couldn't resolve the hostname to an IP address.
|
352 | - `ENETUNREACH`: No internet connection.
|
353 | - `EAI_AGAIN`: DNS lookup timed out.
|
354 |
|
355 | __Note:__ Got does not retry on `POST` by default.
|
356 | __Note:__ If `maxRetryAfter` is set to `undefined`, it will use `options.timeout`.
|
357 | __Note:__ If [`Retry-After`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After) header is greater than `maxRetryAfter`, it will cancel the request.
|
358 | */
|
359 | export interface RetryOptions {
|
360 | limit: number;
|
361 | methods: Method[];
|
362 | statusCodes: number[];
|
363 | errorCodes: string[];
|
364 | calculateDelay: RetryFunction;
|
365 | backoffLimit: number;
|
366 | noise: number;
|
367 | maxRetryAfter?: number;
|
368 | }
|
369 | export declare type CreateConnectionFunction = (options: NativeRequestOptions, oncreate: (error: NodeJS.ErrnoException, socket: Socket) => void) => Socket;
|
370 | export declare type CheckServerIdentityFunction = (hostname: string, certificate: DetailedPeerCertificate) => NodeJS.ErrnoException | void;
|
371 | export interface CacheOptions {
|
372 | shared?: boolean;
|
373 | cacheHeuristic?: number;
|
374 | immutableMinTimeToLive?: number;
|
375 | ignoreCargoCult?: boolean;
|
376 | }
|
377 | declare type PfxObject = {
|
378 | buffer: string | Buffer;
|
379 | passphrase?: string | undefined;
|
380 | };
|
381 | declare type PfxType = string | Buffer | Array<string | Buffer | PfxObject> | undefined;
|
382 | export interface HttpsOptions {
|
383 | alpnProtocols?: string[];
|
384 | rejectUnauthorized?: NativeRequestOptions['rejectUnauthorized'];
|
385 | checkServerIdentity?: CheckServerIdentityFunction;
|
386 | /**
|
387 | Override the default Certificate Authorities ([from Mozilla](https://ccadb-public.secure.force.com/mozilla/IncludedCACertificateReport)).
|
388 |
|
389 | @example
|
390 | ```
|
391 | // Single Certificate Authority
|
392 | await got('https://example.com', {
|
393 | https: {
|
394 | certificateAuthority: fs.readFileSync('./my_ca.pem')
|
395 | }
|
396 | });
|
397 | ```
|
398 | */
|
399 | certificateAuthority?: SecureContextOptions['ca'];
|
400 | /**
|
401 | Private keys in [PEM](https://en.wikipedia.org/wiki/Privacy-Enhanced_Mail) format.
|
402 |
|
403 | [PEM](https://en.wikipedia.org/wiki/Privacy-Enhanced_Mail) allows the option of private keys being encrypted.
|
404 | Encrypted keys will be decrypted with `options.https.passphrase`.
|
405 |
|
406 | Multiple keys with different passphrases can be provided as an array of `{pem: <string | Buffer>, passphrase: <string>}`
|
407 | */
|
408 | key?: SecureContextOptions['key'];
|
409 | /**
|
410 | [Certificate chains](https://en.wikipedia.org/wiki/X.509#Certificate_chains_and_cross-certification) in [PEM](https://en.wikipedia.org/wiki/Privacy-Enhanced_Mail) format.
|
411 |
|
412 | One cert chain should be provided per private key (`options.https.key`).
|
413 |
|
414 | When providing multiple cert chains, they do not have to be in the same order as their private keys in `options.https.key`.
|
415 |
|
416 | If the intermediate certificates are not provided, the peer will not be able to validate the certificate, and the handshake will fail.
|
417 | */
|
418 | certificate?: SecureContextOptions['cert'];
|
419 | /**
|
420 | The passphrase to decrypt the `options.https.key` (if different keys have different passphrases refer to `options.https.key` documentation).
|
421 | */
|
422 | passphrase?: SecureContextOptions['passphrase'];
|
423 | pfx?: PfxType;
|
424 | ciphers?: SecureContextOptions['ciphers'];
|
425 | honorCipherOrder?: SecureContextOptions['honorCipherOrder'];
|
426 | minVersion?: SecureContextOptions['minVersion'];
|
427 | maxVersion?: SecureContextOptions['maxVersion'];
|
428 | signatureAlgorithms?: SecureContextOptions['sigalgs'];
|
429 | tlsSessionLifetime?: SecureContextOptions['sessionTimeout'];
|
430 | dhparam?: SecureContextOptions['dhparam'];
|
431 | ecdhCurve?: SecureContextOptions['ecdhCurve'];
|
432 | certificateRevocationLists?: SecureContextOptions['crl'];
|
433 | }
|
434 | export interface PaginateData<BodyType, ElementType> {
|
435 | response: Response<BodyType>;
|
436 | currentItems: ElementType[];
|
437 | allItems: ElementType[];
|
438 | }
|
439 | export interface FilterData<ElementType> {
|
440 | item: ElementType;
|
441 | currentItems: ElementType[];
|
442 | allItems: ElementType[];
|
443 | }
|
444 | /**
|
445 | All options accepted by `got.paginate()`.
|
446 | */
|
447 | export interface PaginationOptions<ElementType, BodyType> {
|
448 | /**
|
449 | A function that transform [`Response`](#response) into an array of items.
|
450 | This is where you should do the parsing.
|
451 |
|
452 | @default response => JSON.parse(response.body)
|
453 | */
|
454 | transform?: (response: Response<BodyType>) => Promise<ElementType[]> | ElementType[];
|
455 | /**
|
456 | Checks whether the item should be emitted or not.
|
457 |
|
458 | @default ({item, currentItems, allItems}) => true
|
459 | */
|
460 | filter?: (data: FilterData<ElementType>) => boolean;
|
461 | /**
|
462 | The function takes an object with the following properties:
|
463 | - `response` - The current response object.
|
464 | - `currentItems` - Items from the current response.
|
465 | - `allItems` - An empty array, unless `pagination.stackAllItems` is set to `true`, in which case, it's an array of the emitted items.
|
466 |
|
467 | It should return an object representing Got options pointing to the next page. The options are merged automatically with the previous request, therefore the options returned `pagination.paginate(...)` must reflect changes only. If there are no more pages, `false` should be returned.
|
468 |
|
469 | @example
|
470 | ```
|
471 | import got from 'got';
|
472 |
|
473 | const limit = 10;
|
474 |
|
475 | const items = got.paginate('https://example.com/items', {
|
476 | searchParams: {
|
477 | limit,
|
478 | offset: 0
|
479 | },
|
480 | pagination: {
|
481 | paginate: ({response, currentItems}) => {
|
482 | const previousSearchParams = response.request.options.searchParams;
|
483 | const previousOffset = previousSearchParams.get('offset');
|
484 |
|
485 | if (currentItems.length < limit) {
|
486 | return false;
|
487 | }
|
488 |
|
489 | return {
|
490 | searchParams: {
|
491 | ...previousSearchParams,
|
492 | offset: Number(previousOffset) + limit,
|
493 | }
|
494 | };
|
495 | }
|
496 | }
|
497 | });
|
498 |
|
499 | console.log('Items from all pages:', items);
|
500 | ```
|
501 | */
|
502 | paginate?: (data: PaginateData<BodyType, ElementType>) => OptionsInit | false;
|
503 | /**
|
504 | Checks whether the pagination should continue.
|
505 |
|
506 | For example, if you need to stop **before** emitting an entry with some flag, you should use `({item}) => !item.flag`.
|
507 |
|
508 | If you want to stop **after** emitting the entry, you should use
|
509 | `({item, allItems}) => allItems.some(item => item.flag)` instead.
|
510 |
|
511 | @default ({item, currentItems, allItems}) => true
|
512 | */
|
513 | shouldContinue?: (data: FilterData<ElementType>) => boolean;
|
514 | /**
|
515 | The maximum amount of items that should be emitted.
|
516 |
|
517 | @default Infinity
|
518 | */
|
519 | countLimit?: number;
|
520 | /**
|
521 | Milliseconds to wait before the next request is triggered.
|
522 |
|
523 | @default 0
|
524 | */
|
525 | backoff?: number;
|
526 | /**
|
527 | The maximum amount of request that should be triggered.
|
528 | Retries on failure are not counted towards this limit.
|
529 |
|
530 | For example, it can be helpful during development to avoid an infinite number of requests.
|
531 |
|
532 | @default 10000
|
533 | */
|
534 | requestLimit?: number;
|
535 | /**
|
536 | Defines how the property `allItems` in `pagination.paginate`, `pagination.filter` and `pagination.shouldContinue` is managed.
|
537 |
|
538 | By default, the property `allItems` is always an empty array. This setting can be helpful to save on memory usage when working with a large dataset.
|
539 |
|
540 | When set to `true`, the property `allItems` is an array of the emitted items.
|
541 |
|
542 | @default false
|
543 | */
|
544 | stackAllItems?: boolean;
|
545 | }
|
546 | export declare type SearchParameters = Record<string, string | number | boolean | null | undefined>;
|
547 | /**
|
548 | All parsing methods supported by Got.
|
549 | */
|
550 | export declare type ResponseType = 'json' | 'buffer' | 'text';
|
551 | declare type OptionsToSkip = 'searchParameters' | 'followRedirects' | 'auth' | 'toJSON' | 'merge' | 'createNativeRequestOptions' | 'getRequestFunction' | 'getFallbackRequestFunction' | 'freeze';
|
552 | export declare type InternalsType = Except<Options, OptionsToSkip>;
|
553 | export declare type OptionsError = NodeJS.ErrnoException & {
|
554 | options?: Options;
|
555 | };
|
556 | export declare type OptionsInit = Except<Partial<InternalsType>, 'hooks' | 'retry'> & {
|
557 | hooks?: Partial<Hooks>;
|
558 | retry?: Partial<RetryOptions>;
|
559 | };
|
560 | export default class Options {
|
561 | private _unixOptions?;
|
562 | private _internals;
|
563 | private _merging;
|
564 | private readonly _init;
|
565 | constructor(input?: string | URL | OptionsInit, options?: OptionsInit, defaults?: Options);
|
566 | merge(options?: OptionsInit | Options): void;
|
567 | /**
|
568 | Custom request function.
|
569 | The main purpose of this is to [support HTTP2 using a wrapper](https://github.com/szmarczak/http2-wrapper).
|
570 |
|
571 | http.request | https.request
|
572 | */
|
573 | get request(): RequestFunction | undefined;
|
574 | set request(value: RequestFunction | undefined);
|
575 | /**
|
576 | An object representing `http`, `https` and `http2` keys for [`http.Agent`](https://nodejs.org/api/http.html#http_class_http_agent), [`https.Agent`](https://nodejs.org/api/https.html#https_class_https_agent) and [`http2wrapper.Agent`](https://github.com/szmarczak/http2-wrapper#new-http2agentoptions) instance.
|
577 | This is necessary because a request to one protocol might redirect to another.
|
578 | In such a scenario, Got will switch over to the right protocol agent for you.
|
579 |
|
580 | If a key is not present, it will default to a global agent.
|
581 |
|
582 | @example
|
583 | ```
|
584 | import got from 'got';
|
585 | import HttpAgent from 'agentkeepalive';
|
586 |
|
587 | const {HttpsAgent} = HttpAgent;
|
588 |
|
589 | await got('https://sindresorhus.com', {
|
590 | agent: {
|
591 | http: new HttpAgent(),
|
592 | https: new HttpsAgent()
|
593 | }
|
594 | });
|
595 | ```
|
596 | */
|
597 | get agent(): Agents;
|
598 | set agent(value: Agents);
|
599 | get h2session(): ClientHttp2Session | undefined;
|
600 | set h2session(value: ClientHttp2Session | undefined);
|
601 | /**
|
602 | Decompress the response automatically.
|
603 |
|
604 | This will set the `accept-encoding` header to `gzip, deflate, br` unless you set it yourself.
|
605 |
|
606 | If this is disabled, a compressed response is returned as a `Buffer`.
|
607 | This may be useful if you want to handle decompression yourself or stream the raw compressed data.
|
608 |
|
609 | @default true
|
610 | */
|
611 | get decompress(): boolean;
|
612 | set decompress(value: boolean);
|
613 | /**
|
614 | Milliseconds to wait for the server to end the response before aborting the request with `got.TimeoutError` error (a.k.a. `request` property).
|
615 | By default, there's no timeout.
|
616 |
|
617 | This also accepts an `object` with the following fields to constrain the duration of each phase of the request lifecycle:
|
618 |
|
619 | - `lookup` starts when a socket is assigned and ends when the hostname has been resolved.
|
620 | Does not apply when using a Unix domain socket.
|
621 | - `connect` starts when `lookup` completes (or when the socket is assigned if lookup does not apply to the request) and ends when the socket is connected.
|
622 | - `secureConnect` starts when `connect` completes and ends when the handshaking process completes (HTTPS only).
|
623 | - `socket` starts when the socket is connected. See [request.setTimeout](https://nodejs.org/api/http.html#http_request_settimeout_timeout_callback).
|
624 | - `response` starts when the request has been written to the socket and ends when the response headers are received.
|
625 | - `send` starts when the socket is connected and ends with the request has been written to the socket.
|
626 | - `request` starts when the request is initiated and ends when the response's end event fires.
|
627 | */
|
628 | get timeout(): Delays;
|
629 | set timeout(value: Delays);
|
630 | /**
|
631 | When specified, `prefixUrl` will be prepended to `url`.
|
632 | The prefix can be any valid URL, either relative or absolute.
|
633 | A trailing slash `/` is optional - one will be added automatically.
|
634 |
|
635 | __Note__: `prefixUrl` will be ignored if the `url` argument is a URL instance.
|
636 |
|
637 | __Note__: Leading slashes in `input` are disallowed when using this option to enforce consistency and avoid confusion.
|
638 | For example, when the prefix URL is `https://example.com/foo` and the input is `/bar`, there's ambiguity whether the resulting URL would become `https://example.com/foo/bar` or `https://example.com/bar`.
|
639 | The latter is used by browsers.
|
640 |
|
641 | __Tip__: Useful when used with `got.extend()` to create niche-specific Got instances.
|
642 |
|
643 | __Tip__: You can change `prefixUrl` using hooks as long as the URL still includes the `prefixUrl`.
|
644 | If the URL doesn't include it anymore, it will throw.
|
645 |
|
646 | @example
|
647 | ```
|
648 | import got from 'got';
|
649 |
|
650 | await got('unicorn', {prefixUrl: 'https://cats.com'});
|
651 | //=> 'https://cats.com/unicorn'
|
652 |
|
653 | const instance = got.extend({
|
654 | prefixUrl: 'https://google.com'
|
655 | });
|
656 |
|
657 | await instance('unicorn', {
|
658 | hooks: {
|
659 | beforeRequest: [
|
660 | options => {
|
661 | options.prefixUrl = 'https://cats.com';
|
662 | }
|
663 | ]
|
664 | }
|
665 | });
|
666 | //=> 'https://cats.com/unicorn'
|
667 | ```
|
668 | */
|
669 | get prefixUrl(): string | URL;
|
670 | set prefixUrl(value: string | URL);
|
671 | /**
|
672 | __Note #1__: The `body` option cannot be used with the `json` or `form` option.
|
673 |
|
674 | __Note #2__: If you provide this option, `got.stream()` will be read-only.
|
675 |
|
676 | __Note #3__: If you provide a payload with the `GET` or `HEAD` method, it will throw a `TypeError` unless the method is `GET` and the `allowGetBody` option is set to `true`.
|
677 |
|
678 | __Note #4__: This option is not enumerable and will not be merged with the instance defaults.
|
679 |
|
680 | The `content-length` header will be automatically set if `body` is a `string` / `Buffer` / [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData) / [`form-data` instance](https://github.com/form-data/form-data), and `content-length` and `transfer-encoding` are not manually set in `options.headers`.
|
681 |
|
682 | Since Got 12, the `content-length` is not automatically set when `body` is a `fs.createReadStream`.
|
683 | */
|
684 | get body(): string | Buffer | Readable | Generator | AsyncGenerator | FormDataLike | undefined;
|
685 | set body(value: string | Buffer | Readable | Generator | AsyncGenerator | FormDataLike | undefined);
|
686 | /**
|
687 | 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).
|
688 |
|
689 | If the `Content-Type` header is not present, it will be set to `application/x-www-form-urlencoded`.
|
690 |
|
691 | __Note #1__: If you provide this option, `got.stream()` will be read-only.
|
692 |
|
693 | __Note #2__: This option is not enumerable and will not be merged with the instance defaults.
|
694 | */
|
695 | get form(): Record<string, any> | undefined;
|
696 | set form(value: Record<string, any> | undefined);
|
697 | /**
|
698 | JSON body. If the `Content-Type` header is not set, it will be set to `application/json`.
|
699 |
|
700 | __Note #1__: If you provide this option, `got.stream()` will be read-only.
|
701 |
|
702 | __Note #2__: This option is not enumerable and will not be merged with the instance defaults.
|
703 | */
|
704 | get json(): Record<string, any> | undefined;
|
705 | set json(value: Record<string, any> | undefined);
|
706 | /**
|
707 | The URL to request, as a string, a [`https.request` options object](https://nodejs.org/api/https.html#https_https_request_options_callback), or a [WHATWG `URL`](https://nodejs.org/api/url.html#url_class_url).
|
708 |
|
709 | Properties from `options` will override properties in the parsed `url`.
|
710 |
|
711 | If no protocol is specified, it will throw a `TypeError`.
|
712 |
|
713 | __Note__: The query string is **not** parsed as search params.
|
714 |
|
715 | @example
|
716 | ```
|
717 | await got('https://example.com/?query=a b'); //=> https://example.com/?query=a%20b
|
718 | await got('https://example.com/', {searchParams: {query: 'a b'}}); //=> https://example.com/?query=a+b
|
719 |
|
720 | // The query string is overridden by `searchParams`
|
721 | await got('https://example.com/?query=a b', {searchParams: {query: 'a b'}}); //=> https://example.com/?query=a+b
|
722 | ```
|
723 | */
|
724 | get url(): string | URL | undefined;
|
725 | set url(value: string | URL | undefined);
|
726 | /**
|
727 | Cookie support. You don't have to care about parsing or how to store them.
|
728 |
|
729 | __Note__: If you provide this option, `options.headers.cookie` will be overridden.
|
730 | */
|
731 | get cookieJar(): PromiseCookieJar | ToughCookieJar | undefined;
|
732 | set cookieJar(value: PromiseCookieJar | ToughCookieJar | undefined);
|
733 | /**
|
734 | Ignore invalid cookies instead of throwing an error.
|
735 | Only useful when the `cookieJar` option has been set. Not recommended.
|
736 |
|
737 | @default false
|
738 | */
|
739 | get ignoreInvalidCookies(): boolean;
|
740 | set ignoreInvalidCookies(value: boolean);
|
741 | /**
|
742 | Query string that will be added to the request URL.
|
743 | This will override the query string in `url`.
|
744 |
|
745 | If you need to pass in an array, you can do it using a `URLSearchParams` instance.
|
746 |
|
747 | @example
|
748 | ```
|
749 | import got from 'got';
|
750 |
|
751 | const searchParams = new URLSearchParams([['key', 'a'], ['key', 'b']]);
|
752 |
|
753 | await got('https://example.com', {searchParams});
|
754 |
|
755 | console.log(searchParams.toString());
|
756 | //=> 'key=a&key=b'
|
757 | ```
|
758 | */
|
759 | get searchParams(): string | SearchParameters | URLSearchParams | undefined;
|
760 | set searchParams(value: string | SearchParameters | URLSearchParams | undefined);
|
761 | get searchParameters(): unknown;
|
762 | set searchParameters(_value: unknown);
|
763 | get dnsLookup(): CacheableLookup['lookup'] | undefined;
|
764 | set dnsLookup(value: CacheableLookup['lookup'] | undefined);
|
765 | /**
|
766 | An instance of [`CacheableLookup`](https://github.com/szmarczak/cacheable-lookup) used for making DNS lookups.
|
767 | Useful when making lots of requests to different *public* hostnames.
|
768 |
|
769 | `CacheableLookup` uses `dns.resolver4(..)` and `dns.resolver6(...)` under the hood and fall backs to `dns.lookup(...)` when the first two fail, which may lead to additional delay.
|
770 |
|
771 | __Note__: This should stay disabled when making requests to internal hostnames such as `localhost`, `database.local` etc.
|
772 |
|
773 | @default false
|
774 | */
|
775 | get dnsCache(): CacheableLookup | boolean | undefined;
|
776 | set dnsCache(value: CacheableLookup | boolean | undefined);
|
777 | /**
|
778 | User data. `context` is shallow merged and enumerable. If it contains non-enumerable properties they will NOT be merged.
|
779 |
|
780 | @example
|
781 | ```
|
782 | import got from 'got';
|
783 |
|
784 | const instance = got.extend({
|
785 | hooks: {
|
786 | beforeRequest: [
|
787 | options => {
|
788 | if (!options.context || !options.context.token) {
|
789 | throw new Error('Token required');
|
790 | }
|
791 |
|
792 | options.headers.token = options.context.token;
|
793 | }
|
794 | ]
|
795 | }
|
796 | });
|
797 |
|
798 | const context = {
|
799 | token: 'secret'
|
800 | };
|
801 |
|
802 | const response = await instance('https://httpbin.org/headers', {context});
|
803 |
|
804 | // Let's see the headers
|
805 | console.log(response.body);
|
806 | ```
|
807 | */
|
808 | get context(): Record<string, unknown>;
|
809 | set context(value: Record<string, unknown>);
|
810 | /**
|
811 | Hooks allow modifications during the request lifecycle.
|
812 | Hook functions may be async and are run serially.
|
813 | */
|
814 | get hooks(): Hooks;
|
815 | set hooks(value: Hooks);
|
816 | /**
|
817 | Defines if redirect responses should be followed automatically.
|
818 |
|
819 | 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`.
|
820 | This is in accordance with [the spec](https://tools.ietf.org/html/rfc7231#section-6.4.4).
|
821 |
|
822 | @default true
|
823 | */
|
824 | get followRedirect(): boolean;
|
825 | set followRedirect(value: boolean);
|
826 | get followRedirects(): unknown;
|
827 | set followRedirects(_value: unknown);
|
828 | /**
|
829 | If exceeded, the request will be aborted and a `MaxRedirectsError` will be thrown.
|
830 |
|
831 | @default 10
|
832 | */
|
833 | get maxRedirects(): number;
|
834 | set maxRedirects(value: number);
|
835 | /**
|
836 | A cache adapter instance for storing cached response data.
|
837 |
|
838 | @default false
|
839 | */
|
840 | get cache(): string | CacheableRequest.StorageAdapter | boolean | undefined;
|
841 | set cache(value: string | CacheableRequest.StorageAdapter | boolean | undefined);
|
842 | /**
|
843 | Determines if a `got.HTTPError` is thrown for unsuccessful responses.
|
844 |
|
845 | If this is disabled, requests that encounter an error status code will be resolved with the `response` instead of throwing.
|
846 | This may be useful if you are checking for resource availability and are expecting error responses.
|
847 |
|
848 | @default true
|
849 | */
|
850 | get throwHttpErrors(): boolean;
|
851 | set throwHttpErrors(value: boolean);
|
852 | get username(): string;
|
853 | set username(value: string);
|
854 | get password(): string;
|
855 | set password(value: string);
|
856 | /**
|
857 | If set to `true`, Got will additionally accept HTTP2 requests.
|
858 |
|
859 | It will choose either HTTP/1.1 or HTTP/2 depending on the ALPN protocol.
|
860 |
|
861 | __Note__: This option requires Node.js 15.10.0 or newer as HTTP/2 support on older Node.js versions is very buggy.
|
862 |
|
863 | __Note__: Overriding `options.request` will disable HTTP2 support.
|
864 |
|
865 | @default false
|
866 |
|
867 | @example
|
868 | ```
|
869 | import got from 'got';
|
870 |
|
871 | const {headers} = await got('https://nghttp2.org/httpbin/anything', {http2: true});
|
872 |
|
873 | console.log(headers.via);
|
874 | //=> '2 nghttpx'
|
875 | ```
|
876 | */
|
877 | get http2(): boolean;
|
878 | set http2(value: boolean);
|
879 | /**
|
880 | Set this to `true` to allow sending body for the `GET` method.
|
881 | However, the [HTTP/2 specification](https://tools.ietf.org/html/rfc7540#section-8.1.3) says that `An HTTP GET request includes request header fields and no payload body`, therefore when using the HTTP/2 protocol this option will have no effect.
|
882 | This option is only meant to interact with non-compliant servers when you have no other choice.
|
883 |
|
884 | __Note__: The [RFC 7321](https://tools.ietf.org/html/rfc7231#section-4.3.1) doesn't specify any particular behavior for the GET method having a payload, therefore __it's considered an [anti-pattern](https://en.wikipedia.org/wiki/Anti-pattern)__.
|
885 |
|
886 | @default false
|
887 | */
|
888 | get allowGetBody(): boolean;
|
889 | set allowGetBody(value: boolean);
|
890 | /**
|
891 | Request headers.
|
892 |
|
893 | Existing headers will be overwritten. Headers set to `undefined` will be omitted.
|
894 |
|
895 | @default {}
|
896 | */
|
897 | get headers(): Headers;
|
898 | set headers(value: Headers);
|
899 | /**
|
900 | Specifies if the redirects should be [rewritten as `GET`](https://tools.ietf.org/html/rfc7231#section-6.4).
|
901 |
|
902 | If `false`, when sending a POST request and receiving a `302`, it will resend the body to the new location using the same HTTP method (`POST` in this case).
|
903 |
|
904 | @default false
|
905 | */
|
906 | get methodRewriting(): boolean;
|
907 | set methodRewriting(value: boolean);
|
908 | /**
|
909 | Indicates which DNS record family to use.
|
910 |
|
911 | Values:
|
912 | - `undefined`: IPv4 (if present) or IPv6
|
913 | - `4`: Only IPv4
|
914 | - `6`: Only IPv6
|
915 |
|
916 | @default undefined
|
917 | */
|
918 | get dnsLookupIpVersion(): DnsLookupIpVersion;
|
919 | set dnsLookupIpVersion(value: DnsLookupIpVersion);
|
920 | /**
|
921 | A function used to parse JSON responses.
|
922 |
|
923 | @example
|
924 | ```
|
925 | import got from 'got';
|
926 | import Bourne from '@hapi/bourne';
|
927 |
|
928 | const parsed = await got('https://example.com', {
|
929 | parseJson: text => Bourne.parse(text)
|
930 | }).json();
|
931 |
|
932 | console.log(parsed);
|
933 | ```
|
934 | */
|
935 | get parseJson(): ParseJsonFunction;
|
936 | set parseJson(value: ParseJsonFunction);
|
937 | /**
|
938 | A function used to stringify the body of JSON requests.
|
939 |
|
940 | @example
|
941 | ```
|
942 | import got from 'got';
|
943 |
|
944 | await got.post('https://example.com', {
|
945 | stringifyJson: object => JSON.stringify(object, (key, value) => {
|
946 | if (key.startsWith('_')) {
|
947 | return;
|
948 | }
|
949 |
|
950 | return value;
|
951 | }),
|
952 | json: {
|
953 | some: 'payload',
|
954 | _ignoreMe: 1234
|
955 | }
|
956 | });
|
957 | ```
|
958 |
|
959 | @example
|
960 | ```
|
961 | import got from 'got';
|
962 |
|
963 | await got.post('https://example.com', {
|
964 | stringifyJson: object => JSON.stringify(object, (key, value) => {
|
965 | if (typeof value === 'number') {
|
966 | return value.toString();
|
967 | }
|
968 |
|
969 | return value;
|
970 | }),
|
971 | json: {
|
972 | some: 'payload',
|
973 | number: 1
|
974 | }
|
975 | });
|
976 | ```
|
977 | */
|
978 | get stringifyJson(): StringifyJsonFunction;
|
979 | set stringifyJson(value: StringifyJsonFunction);
|
980 | /**
|
981 | An object representing `limit`, `calculateDelay`, `methods`, `statusCodes`, `maxRetryAfter` and `errorCodes` fields for maximum retry count, retry handler, allowed methods, allowed status codes, maximum [`Retry-After`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After) time and allowed error codes.
|
982 |
|
983 | Delays between retries counts with function `1000 * Math.pow(2, retry) + Math.random() * 100`, where `retry` is attempt number (starts from 1).
|
984 |
|
985 | 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.
|
986 | The function must return a delay in milliseconds (or a Promise resolving with it) (`0` return value cancels retry).
|
987 |
|
988 | By default, it retries *only* on the specified methods, status codes, and on these network errors:
|
989 |
|
990 | - `ETIMEDOUT`: One of the [timeout](#timeout) limits were reached.
|
991 | - `ECONNRESET`: Connection was forcibly closed by a peer.
|
992 | - `EADDRINUSE`: Could not bind to any free port.
|
993 | - `ECONNREFUSED`: Connection was refused by the server.
|
994 | - `EPIPE`: The remote side of the stream being written has been closed.
|
995 | - `ENOTFOUND`: Couldn't resolve the hostname to an IP address.
|
996 | - `ENETUNREACH`: No internet connection.
|
997 | - `EAI_AGAIN`: DNS lookup timed out.
|
998 |
|
999 | __Note__: If `maxRetryAfter` is set to `undefined`, it will use `options.timeout`.
|
1000 | __Note__: If [`Retry-After`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After) header is greater than `maxRetryAfter`, it will cancel the request.
|
1001 | */
|
1002 | get retry(): Partial<RetryOptions>;
|
1003 | set retry(value: Partial<RetryOptions>);
|
1004 | /**
|
1005 | From `http.RequestOptions`.
|
1006 |
|
1007 | The IP address used to send the request from.
|
1008 | */
|
1009 | get localAddress(): string | undefined;
|
1010 | set localAddress(value: string | undefined);
|
1011 | /**
|
1012 | The HTTP method used to make the request.
|
1013 |
|
1014 | @default 'GET'
|
1015 | */
|
1016 | get method(): Method;
|
1017 | set method(value: Method);
|
1018 | get createConnection(): CreateConnectionFunction | undefined;
|
1019 | set createConnection(value: CreateConnectionFunction | undefined);
|
1020 | /**
|
1021 | From `http-cache-semantics`
|
1022 |
|
1023 | @default {}
|
1024 | */
|
1025 | get cacheOptions(): CacheOptions;
|
1026 | set cacheOptions(value: CacheOptions);
|
1027 | /**
|
1028 | Options for the advanced HTTPS API.
|
1029 | */
|
1030 | get https(): HttpsOptions;
|
1031 | set https(value: HttpsOptions);
|
1032 | /**
|
1033 | [Encoding](https://nodejs.org/api/buffer.html#buffer_buffers_and_character_encodings) to be used on `setEncoding` of the response data.
|
1034 |
|
1035 | To get a [`Buffer`](https://nodejs.org/api/buffer.html), you need to set `responseType` to `buffer` instead.
|
1036 | Don't set this option to `null`.
|
1037 |
|
1038 | __Note__: This doesn't affect streams! Instead, you need to do `got.stream(...).setEncoding(encoding)`.
|
1039 |
|
1040 | @default 'utf-8'
|
1041 | */
|
1042 | get encoding(): BufferEncoding | undefined;
|
1043 | set encoding(value: BufferEncoding | undefined);
|
1044 | /**
|
1045 | When set to `true` the promise will return the Response body instead of the Response object.
|
1046 |
|
1047 | @default false
|
1048 | */
|
1049 | get resolveBodyOnly(): boolean;
|
1050 | set resolveBodyOnly(value: boolean);
|
1051 | /**
|
1052 | Returns a `Stream` instead of a `Promise`.
|
1053 | This is equivalent to calling `got.stream(url, options?)`.
|
1054 |
|
1055 | @default false
|
1056 | */
|
1057 | get isStream(): boolean;
|
1058 | set isStream(value: boolean);
|
1059 | /**
|
1060 | The parsing method.
|
1061 |
|
1062 | The promise also has `.text()`, `.json()` and `.buffer()` methods which return another Got promise for the parsed body.
|
1063 |
|
1064 | It's like setting the options to `{responseType: 'json', resolveBodyOnly: true}` but without affecting the main Got promise.
|
1065 |
|
1066 | __Note__: When using streams, this option is ignored.
|
1067 |
|
1068 | @example
|
1069 | ```
|
1070 | const responsePromise = got(url);
|
1071 | const bufferPromise = responsePromise.buffer();
|
1072 | const jsonPromise = responsePromise.json();
|
1073 |
|
1074 | const [response, buffer, json] = Promise.all([responsePromise, bufferPromise, jsonPromise]);
|
1075 | // `response` is an instance of Got Response
|
1076 | // `buffer` is an instance of Buffer
|
1077 | // `json` is an object
|
1078 | ```
|
1079 |
|
1080 | @example
|
1081 | ```
|
1082 | // This
|
1083 | const body = await got(url).json();
|
1084 |
|
1085 | // is semantically the same as this
|
1086 | const body = await got(url, {responseType: 'json', resolveBodyOnly: true});
|
1087 | ```
|
1088 | */
|
1089 | get responseType(): ResponseType;
|
1090 | set responseType(value: ResponseType);
|
1091 | get pagination(): PaginationOptions<unknown, unknown>;
|
1092 | set pagination(value: PaginationOptions<unknown, unknown>);
|
1093 | get auth(): unknown;
|
1094 | set auth(_value: unknown);
|
1095 | get setHost(): boolean;
|
1096 | set setHost(value: boolean);
|
1097 | get maxHeaderSize(): number | undefined;
|
1098 | set maxHeaderSize(value: number | undefined);
|
1099 | toJSON(): {
|
1100 | headers: Headers;
|
1101 | timeout: Delays;
|
1102 | request: RequestFunction | undefined;
|
1103 | username: string;
|
1104 | password: string;
|
1105 | json: Record<string, any> | undefined;
|
1106 | retry: Partial<RetryOptions>;
|
1107 | agent: Agents;
|
1108 | h2session: http2wrapper.ClientHttp2Session | undefined;
|
1109 | decompress: boolean;
|
1110 | prefixUrl: string | URL;
|
1111 | body: string | Readable | Buffer | Generator<unknown, any, unknown> | AsyncGenerator<unknown, any, unknown> | FormDataLike | undefined;
|
1112 | form: Record<string, any> | undefined;
|
1113 | url: string | URL | undefined;
|
1114 | cookieJar: PromiseCookieJar | ToughCookieJar | undefined;
|
1115 | ignoreInvalidCookies: boolean;
|
1116 | searchParams: string | SearchParameters | URLSearchParams | undefined;
|
1117 | dnsLookup: {
|
1118 | (hostname: string, family: import("cacheable-lookup").IPFamily, callback: (error: NodeJS.ErrnoException | null, address: string, family: import("cacheable-lookup").IPFamily) => void): void;
|
1119 | (hostname: string, callback: (error: NodeJS.ErrnoException | null, address: string, family: import("cacheable-lookup").IPFamily) => void): void;
|
1120 | (hostname: string, options: import("cacheable-lookup").LookupOptions & {
|
1121 | all: true;
|
1122 | }, callback: (error: NodeJS.ErrnoException | null, result: readonly import("cacheable-lookup").EntryObject[]) => void): void;
|
1123 | (hostname: string, options: import("cacheable-lookup").LookupOptions, callback: (error: NodeJS.ErrnoException | null, address: string, family: import("cacheable-lookup").IPFamily) => void): void;
|
1124 | } | undefined;
|
1125 | dnsCache: boolean | CacheableLookup | undefined;
|
1126 | context: Record<string, unknown>;
|
1127 | hooks: Hooks;
|
1128 | followRedirect: boolean;
|
1129 | maxRedirects: number;
|
1130 | cache: string | boolean | CacheableRequest.StorageAdapter | undefined;
|
1131 | throwHttpErrors: boolean;
|
1132 | http2: boolean;
|
1133 | allowGetBody: boolean;
|
1134 | methodRewriting: boolean;
|
1135 | dnsLookupIpVersion: DnsLookupIpVersion;
|
1136 | parseJson: ParseJsonFunction;
|
1137 | stringifyJson: StringifyJsonFunction;
|
1138 | localAddress: string | undefined;
|
1139 | method: Method;
|
1140 | createConnection: CreateConnectionFunction | undefined;
|
1141 | cacheOptions: CacheOptions;
|
1142 | https: HttpsOptions;
|
1143 | encoding: BufferEncoding | undefined;
|
1144 | resolveBodyOnly: boolean;
|
1145 | isStream: boolean;
|
1146 | responseType: ResponseType;
|
1147 | pagination: PaginationOptions<unknown, unknown>;
|
1148 | setHost: boolean;
|
1149 | maxHeaderSize: number | undefined;
|
1150 | };
|
1151 | createNativeRequestOptions(): {
|
1152 | ALPNProtocols: string[] | undefined;
|
1153 | ca: string | Buffer | (string | Buffer)[] | undefined;
|
1154 | cert: string | Buffer | (string | Buffer)[] | undefined;
|
1155 | key: string | Buffer | (Buffer | import("tls").KeyObject)[] | undefined;
|
1156 | passphrase: string | undefined;
|
1157 | pfx: PfxType;
|
1158 | rejectUnauthorized: boolean | undefined;
|
1159 | checkServerIdentity: CheckServerIdentityFunction | typeof checkServerIdentity;
|
1160 | ciphers: string | undefined;
|
1161 | honorCipherOrder: boolean | undefined;
|
1162 | minVersion: import("tls").SecureVersion | undefined;
|
1163 | maxVersion: import("tls").SecureVersion | undefined;
|
1164 | sigalgs: string | undefined;
|
1165 | sessionTimeout: number | undefined;
|
1166 | dhparam: string | Buffer | undefined;
|
1167 | ecdhCurve: string | undefined;
|
1168 | crl: string | Buffer | (string | Buffer)[] | undefined;
|
1169 | lookup: {
|
1170 | (hostname: string, family: import("cacheable-lookup").IPFamily, callback: (error: NodeJS.ErrnoException | null, address: string, family: import("cacheable-lookup").IPFamily) => void): void;
|
1171 | (hostname: string, callback: (error: NodeJS.ErrnoException | null, address: string, family: import("cacheable-lookup").IPFamily) => void): void;
|
1172 | (hostname: string, options: import("cacheable-lookup").LookupOptions & {
|
1173 | all: true;
|
1174 | }, callback: (error: NodeJS.ErrnoException | null, result: readonly import("cacheable-lookup").EntryObject[]) => void): void;
|
1175 | (hostname: string, options: import("cacheable-lookup").LookupOptions, callback: (error: NodeJS.ErrnoException | null, address: string, family: import("cacheable-lookup").IPFamily) => void): void;
|
1176 | } | undefined;
|
1177 | family: DnsLookupIpVersion;
|
1178 | agent: false | Agents | http.Agent | undefined;
|
1179 | setHost: boolean;
|
1180 | method: Method;
|
1181 | maxHeaderSize: number | undefined;
|
1182 | localAddress: string | undefined;
|
1183 | headers: Headers;
|
1184 | createConnection: CreateConnectionFunction | undefined;
|
1185 | timeout: number | undefined;
|
1186 | h2session: http2wrapper.ClientHttp2Session | undefined;
|
1187 | signal?: AbortSignal | undefined;
|
1188 | protocol?: string | null | undefined;
|
1189 | host?: string | null | undefined;
|
1190 | hostname?: string | null | undefined;
|
1191 | port?: string | number | null | undefined;
|
1192 | defaultPort?: string | number | undefined;
|
1193 | socketPath?: string | undefined;
|
1194 | path?: string | null | undefined;
|
1195 | auth?: string | null | undefined;
|
1196 | _defaultAgent?: http.Agent | undefined;
|
1197 | clientCertEngine?: string | undefined;
|
1198 | privateKeyEngine?: string | undefined;
|
1199 | privateKeyIdentifier?: string | undefined;
|
1200 | secureOptions?: number | undefined;
|
1201 | secureProtocol?: string | undefined;
|
1202 | sessionIdContext?: string | undefined;
|
1203 | ticketKeys?: Buffer | undefined;
|
1204 | servername?: string | undefined;
|
1205 | shared?: boolean | undefined;
|
1206 | cacheHeuristic?: number | undefined;
|
1207 | immutableMinTimeToLive?: number | undefined;
|
1208 | ignoreCargoCult?: boolean | undefined;
|
1209 | };
|
1210 | getRequestFunction(): RequestFunction | typeof https.request | undefined;
|
1211 | getFallbackRequestFunction(): RequestFunction | typeof https.request | undefined;
|
1212 | freeze(): void;
|
1213 | }
|
1214 | export {};
|
1215 |
|
\ | No newline at end of file |