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.

50 lines (49 loc) 1.51 kB
import * as plugins from './plugins.js'; import * as types from './types.js'; import { CoreResponse as AbstractCoreResponse } from '../core_base/response.js'; /** * Node.js implementation of Core Response class that provides a fetch-like API */ export declare class CoreResponse<T = any> extends AbstractCoreResponse<T> implements types.INodeResponse<T> { private incomingMessage; private bodyBufferPromise; private _autoDrainTimeout; readonly ok: boolean; readonly status: number; readonly statusText: string; readonly headers: plugins.http.IncomingHttpHeaders; readonly url: string; constructor(incomingMessage: plugins.http.IncomingMessage, url: string, options?: types.ICoreRequestOptions); /** * Override to also cancel auto-drain when body is consumed */ protected ensureNotConsumed(): void; /** * 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 web-style ReadableStream */ stream(): ReadableStream<Uint8Array> | null; /** * Get response as a Node.js readable stream */ streamNode(): NodeJS.ReadableStream; /** * Get the raw IncomingMessage (for legacy compatibility) */ raw(): plugins.http.IncomingMessage; }