UNPKG

1.1 kBTypeScriptView Raw
1export interface IRequestOptions {
2 /**
3 * URL string.
4 */
5 url: string;
6 /**
7 * Request method.
8 */
9 method?: string;
10 /**
11 * Request headers.
12 */
13 headers?: {
14 [key: string]: string;
15 };
16 /**
17 * Gzip compression.
18 */
19 gzip?: boolean;
20 /**
21 * Body encoding used for callback functions.
22 */
23 encoding?: string | null;
24}
25export interface IRequestResponse {
26 /**
27 * Status code.
28 */
29 statusCode: number;
30 /**
31 * Response headers, all lowercase.
32 */
33 headers: {
34 [key: string]: string;
35 };
36}
37export declare type IRequestCallback = (error: any, response: IRequestResponse, body: any) => void;
38export declare type IRequest = (options: IRequestOptions, cb?: IRequestCallback) => any;
39/**
40 * Extract file info from a URL.
41 *
42 * @param uri The URI to extract info from.
43 * @param req Optional custom request function or null.
44 * @returns File info.
45 */
46export declare function extract(uri: string, req?: IRequest | null): Promise<{
47 download: string;
48 filename: string | null;
49}>;