UNPKG

@push.rocks/smartrequest

Version:

A module for modern HTTP/HTTPS requests with support for form data, file uploads, JSON, binary data, streams, and more.

45 lines (44 loc) 1.17 kB
import * as plugins from './plugins.js'; import * as types from './types.js'; /** * Core Response class that provides a fetch-like API */ export declare class CoreResponse<T = any> implements types.ICoreResponse<T> { private incomingMessage; private bodyBufferPromise; private consumed; readonly ok: boolean; readonly status: number; readonly statusText: string; readonly headers: plugins.http.IncomingHttpHeaders; readonly url: string; constructor(incomingMessage: plugins.http.IncomingMessage, url: string); /** * Ensures the body can only be consumed once */ private ensureNotConsumed; /** * Collects the body as a buffer */ private collectBody; /** * Parse response as JSON */ json(): Promise<T>; /** * Get response as text */ text(): Promise<string>; /** * Get response as ArrayBuffer */ arrayBuffer(): Promise<ArrayBuffer>; /** * Get response as a readable stream */ stream(): NodeJS.ReadableStream; /** * Get the raw IncomingMessage (for legacy compatibility) */ raw(): plugins.http.IncomingMessage; }