1 |
|
2 | import { EventEmitter } from "events";
|
3 | import { OutgoingHttpHeaders, RequestOptions } from "http";
|
4 | import { Transform } from "stream";
|
5 | import { CancellationToken } from "./CancellationToken";
|
6 | import { ProgressInfo } from "./ProgressCallbackTransform";
|
7 | export { CancellationToken, CancellationError } from "./CancellationToken";
|
8 | export { ProgressCallbackTransform, ProgressInfo } from "./ProgressCallbackTransform";
|
9 | export interface RequestHeaders extends OutgoingHttpHeaders {
|
10 | [key: string]: string;
|
11 | }
|
12 | export interface RequestOptionsEx extends RequestOptions {
|
13 | }
|
14 | export interface Response extends EventEmitter {
|
15 | statusCode?: number;
|
16 | statusMessage?: string;
|
17 | headers: any;
|
18 | setEncoding(encoding: string): void;
|
19 | }
|
20 | export interface DownloadOptions {
|
21 | readonly headers?: OutgoingHttpHeaders | null;
|
22 | readonly skipDirCreation?: boolean;
|
23 | readonly sha2?: string | null;
|
24 | readonly sha512?: string | null;
|
25 | readonly cancellationToken: CancellationToken;
|
26 | onProgress?(progress: ProgressInfo): void;
|
27 | }
|
28 | export declare class HttpError extends Error {
|
29 | readonly response: {
|
30 | statusMessage?: string | undefined;
|
31 | statusCode?: number | undefined;
|
32 | headers?: {
|
33 | [key: string]: Array<string>;
|
34 | } | undefined;
|
35 | };
|
36 | description: any | null;
|
37 | constructor(response: {
|
38 | statusMessage?: string | undefined;
|
39 | statusCode?: number | undefined;
|
40 | headers?: {
|
41 | [key: string]: Array<string>;
|
42 | } | undefined;
|
43 | }, description?: any | null);
|
44 | }
|
45 | export declare function parseJson(result: Promise<string | null>): Promise<any>;
|
46 | export declare abstract class HttpExecutor<REQUEST> {
|
47 | protected readonly maxRedirects: number;
|
48 | request(options: RequestOptions, cancellationToken?: CancellationToken, data?: {
|
49 | [name: string]: any;
|
50 | } | null): Promise<string | null>;
|
51 | protected abstract doApiRequest(options: RequestOptions, cancellationToken: CancellationToken, requestProcessor: (request: REQUEST, reject: (error: Error) => void) => void, redirectCount: number): Promise<string>;
|
52 | protected handleResponse(response: Response, options: RequestOptionsEx, cancellationToken: CancellationToken, resolve: (data?: any) => void, reject: (error: Error) => void, redirectCount: number, requestProcessor: (request: REQUEST, reject: (error: Error) => void) => void): void;
|
53 | protected abstract doRequest(options: any, callback: (response: any) => void): any;
|
54 | protected doDownload(requestOptions: any, destination: string, redirectCount: number, options: DownloadOptions, callback: (error: Error | null) => void, onCancel: (callback: () => void) => void): void;
|
55 | protected addTimeOutHandler(request: any, callback: (error: Error) => void): void;
|
56 | }
|
57 | export declare function configureRequestOptionsFromUrl(url: string, options: RequestOptions): RequestOptions;
|
58 | export declare class DigestTransform extends Transform {
|
59 | private readonly expected;
|
60 | private readonly algorithm;
|
61 | private readonly encoding;
|
62 | private readonly digester;
|
63 | constructor(expected: string, algorithm: string, encoding: "hex" | "base64" | "latin1");
|
64 | _transform(chunk: any, encoding: string, callback: any): void;
|
65 | _flush(callback: any): void;
|
66 | }
|
67 | export declare function safeGetHeader(response: any, headerKey: string): any;
|
68 | export declare function configureRequestOptions(options: RequestOptions, token?: string | null, method?: "GET" | "DELETE" | "PUT"): RequestOptions;
|
69 | export declare function dumpRequestOptions(options: RequestOptions): string;
|