///
///
import { Stream } from "stream";
import { IncomingHttpHeaders } from "http";
import { AxiosResponse, Method } from "axios";
import download from "download";
import { Crawler } from "./crawler";
export declare type JSONPrimitive = string | number | boolean | null;
export declare type JSONObject = {
[key: string]: JSONValue;
};
export interface JSONArray extends Array {
}
export declare type JSONValue = JSONPrimitive | JSONObject | JSONArray;
export { Method };
export interface DownloadBody {
filepath: string;
options: download.DownloadOptions;
}
export declare type Body = string | JSONValue | DownloadBody | Buffer | ArrayBuffer | ArrayBufferView | Uint8Array | URLSearchParams | Stream | null;
export declare type HTTPHeaders = IncomingHttpHeaders;
export interface UrlCustomer {
url: string;
method?: Method;
body?: Body;
headers?: HTTPHeaders;
}
export declare type Url = string | UrlCustomer;
export interface Response extends AxiosResponse, CheerioSelector, CheerioAPI {
/**
* The crawler instance.
*/
crawler: Crawler;
/**
* How many times(ms) it takes.
*/
times: number;
/**
* Download the resource
* @param url The resource url
* @param filepath The filepath which is the resource downloaded
* @param options
*/
download(url: string, filepath: string, options?: download.DownloadOptions): Promise;
/**
* Download the resource in queue
* @param url The resource url
* @param filepath The filepath which is the resource downloaded
* @param options
*/
downloadInQueue(url: string, filepath: string, options?: download.DownloadOptions): void;
/**
* Go to the next url
* @param Url
*/
follow(url: Url): void;
/**
* retry again. There may be duplicate data.
*/
retry(): void;
}
export declare class Http {
private crawler;
private source;
constructor(crawler: Crawler);
/**
* Send request
* @param url
* @param method
* @param body
* @param httpHeaders
*/
request(url: string, method?: Method, body?: Body, httpHeaders?: HTTPHeaders): Promise;
/**
* Append download task to the pool
* @param url
* @param filepath
* @param options
*/
download(url: string, filepath: string, options?: download.DownloadOptions): void;
/**
* Download resource
* @param url
* @param filepath
* @param options
*/
downloadResource(url: string, filepath: string, options?: download.DownloadOptions): Promise;
/**
* Cancel all request
*/
cancel(): void;
private createResponse;
}