/** * HTTP 工具 —— 简单包装 fetch(去 context.ts 直接用,绕开 ctx.get 因为: * 1. 这些是公网数据源,不需要 baseUrl 相对路径 * 2. 各数据源对 UA / Referer / 编码要求不同,需统一管理 * 3. 数据源失败可单独抛错,与 cli-sdk 错误体系分离) * * 设计: * - 真实超时(AbortSignal.timeout) * - 重试(指数退避,默认 2 次) * - 通用 User-Agent * - JSON / GBK 自动识别(腾讯/东财接口部分返回 GBK) */ export interface HttpOptions { method?: "GET" | "POST"; /** query(自动拼到 url) */ query?: Record; /** 请求头 */ headers?: Record; /** body(JSON.stringify 或原文) */ body?: string | Record; /** 超时(ms) */ timeout?: number; /** 重试次数(默认 2) */ retries?: number; /** 响应类型 */ responseType?: "json" | "text" | "gbk"; } export interface HttpResponse { status: number; data: T; headers: Record; } /** * HTTP 请求(带重试 + 超时) * * 失败策略: * - 网络错误(timeout / fetch reject)→ 重试 * - 5xx / 429 → 重试 * - 4xx(非 429)→ 直接抛错 */ export declare function httpFetch(url: string, opts?: HttpOptions): Promise>; /** GET 简写 */ export declare function httpGet(url: string, opts?: Omit): Promise>; /** POST 简写(JSON body) */ export declare function httpPost(url: string, body: unknown, opts?: Omit): Promise>; //# sourceMappingURL=http.d.ts.map