import type { ReadableStream } from 'web-streams-polyfill'; import { ProgressData, ProgressEventTarget } from './utility'; export declare enum BodyRequestMethods { POST = "POST", PUT = "PUT", PATCH = "PATCH", DELETE = "DELETE" } export interface RequestOptions { withCredentials?: boolean; timeout?: number; responseType?: XMLHttpRequestResponseType; } export interface Request extends RequestOptions { method?: 'HEAD' | 'GET' | keyof typeof BodyRequestMethods; path: string | URL; headers?: HeadersInit; body?: BodyInit | HTMLFormElement | T; signal?: AbortSignal; } export interface Response { status: number; statusText: string; headers: Record; body?: B; } export declare class HTTPError extends URIError { request: Request; response: Response; constructor(message: string, request: Request, response: Response); } export type LinkHeader = Record; export declare const headerParser: { Link: (value: string) => LinkHeader; }; export declare const parseHeaders: (raw: string) => Response["headers"]; export declare function parseBody(raw: string, contentType: string): T; export interface RequestResult { response: Promise>; upload?: AsyncGenerator; download: AsyncGenerator; } export declare function requestXHR({ method, path, headers, body, signal, ...rest }: Request): RequestResult; export declare function requestFetch({ path, method, headers, withCredentials, body, signal, timeout, responseType }: Request): RequestResult; export declare function parseResponse({ status, statusText, headers, body }: globalThis.Response, responseType: Request['responseType'], downloadProgress: ProgressEventTarget): Promise>; export declare function parseFetchBody(stream: ReadableStream, contentType: string, responseType: Request['responseType']): Promise; export declare const request: typeof requestXHR;