UNPKG

urllib

Version:

Help in opening URLs (mostly HTTP) in a complex world — basic and digest authentication, redirections, cookies and more. Base undici fetch API.

41 lines (40 loc) 1.59 kB
/// <reference types="node" /> /// <reference types="node" /> /// <reference types="node" /> import { EventEmitter } from 'events'; import { LookupFunction } from 'net'; import { CheckAddressFunction } from './HttpAgent'; import { RequestURL, RequestOptions } from './Request'; import { HttpClientResponse } from './Response'; export declare type ClientOptions = { defaultArgs?: RequestOptions; /** * Custom DNS lookup function, default is `dns.lookup`. */ lookup?: LookupFunction; /** * check request address to protect from SSRF and similar attacks. * It receive two arguments(ip and family) and should return true or false to identified the address is legal or not. * It rely on lookup and have the same version requirement. */ checkAddress?: CheckAddressFunction; connect?: { key?: string | Buffer; /** * A string or Buffer containing the certificate key of the client in PEM format. * Notes: This is necessary only if using the client certificate authentication */ cert?: string | Buffer; /** * If true, the server certificate is verified against the list of supplied CAs. * An 'error' event is emitted if verification fails.Default: true. */ rejectUnauthorized?: boolean; }; }; export declare const HEADER_USER_AGENT: string; export declare class HttpClient extends EventEmitter { #private; constructor(clientOptions?: ClientOptions); request(url: RequestURL, options?: RequestOptions): Promise<HttpClientResponse>; }