import { type BasicAuth, type BearerAuth } from './net.common.ts';
export * from './net.common.ts';
export interface FullResponse<TBody extends ArrayBuffer | string> {
    status: number;
    headers: Headers;
    body: TBody;
}
export interface RequestOptions {
    method?: 'GET' | 'POST' | 'PUT' | 'HEAD' | 'DELETE' | 'PATCH';
    queries?: Record<string, any>;
    headers?: Record<string, string> | Headers;
    body?: string | Record<string, any> | ArrayBufferView | ArrayBuffer | Blob | URLSearchParams | FormData;
    type?: 'application/json' | 'application/x-www-form-urlencoded' | 'multipart/form-data';
    encoding?: 'binary';
    retries?: true | number;
    timeout?: number;
    auth?: BasicAuth | BearerAuth;
    cookies?: Record<string, string>;
    cors?: boolean;
    credentials?: RequestCredentials;
}
export interface RequestRawOptions extends RequestOptions {
    raw: true;
}
export interface RequestFullOptions extends RequestOptions {
    full: true;
}
export interface RequestError extends Error {
    url: URL;
    options: RequestOptions | RequestFullOptions | RequestRawOptions;
    response?: FullResponse<string>;
}
/**
    - url: 可以只有 pathname 部分
    - options?:
        - method?: `有 body 时为 POST, 否则为 GET` 'GET' | 'POST' | ··
        - queries?: 添加到 url 上的参数，是 Record<string, any>，true/false 会被转换为 0/1
        - headers?: http 请求头 (Record<string, string> 或者 Headers 类型)，其中 key 必须是小写的
        - body?: http 请求体，可以是 string, Record<string, any> (会自动 JSON.stringify), ArrayBuffer(View), Blob,
            URLSearchParams (type 为 x-www-form-urlencoded), FormData (type 为 form-data)
        - type?: `'application/json'` 有 body 时设置 http 请求头中的 content-type 头
        - encoding?: 设置为 'binary' 时返回 ArrayBuffer 的 body
        - retries?: `false` 可以传入 true (默认 2 次) 或 重试次数
        - timeout?: `5 * 1000`
        - auth?: BasicAuth | BearerAuth
        - raw?: `false` 传入后返回整个 response  */
export declare function request(url: string | URL): Promise<string>;
export declare function request(url: string | URL, options: RequestRawOptions): Promise<Response>;
export declare function request(url: string | URL, options: RequestFullOptions & {
    encoding: 'binary';
}): Promise<FullResponse<ArrayBuffer>>;
export declare function request(url: string | URL, options: RequestFullOptions): Promise<FullResponse<string>>;
export declare function request(url: string | URL, options: RequestOptions & {
    encoding: 'binary';
}): Promise<ArrayBuffer>;
export declare function request(url: string | URL, options: RequestOptions): Promise<string>;
/** 发起 http 请求并将响应体作为 json 解析 */
export declare function request_json<T = any>(url: string, options?: RequestOptions): Promise<T>;
