import { Buffer } from "node:buffer"; import { Readable } from "node:stream"; import { HttpResponse } from "./response.js"; import { SizeHint } from "./size-hint.js"; import { TO_HTTP_RESPONSE, type ToHttpResponse } from "./to-response.js"; /** * Represents the body of an HTTP message, allowing for handling of various body * types like streams, strings, buffers, and more. * * Provides utilities for creating a body instance and transforming it into an * HTTP response. */ export declare class Body implements ToHttpResponse { readonly sizeHint: SizeHint; readonly contentTypeHint: string | null; readonly readable: ReadableStream; /** * Creates a new {@link Body}. * * @throws {@link !Error} if the provided stream is not readable. */ constructor(stream: ReadableStream, sizeHint?: SizeHint, contentTypeHint?: string); /** * Creates a new {@link Body} from a {@link BodyLike} value. */ static from(body: BodyLike): Body; [TO_HTTP_RESPONSE](): HttpResponse; } /** * Represents any value that can be treated as a body payload in HTTP response * handling. * * This type is a union of various formats that a body can take, enabling * flexibility in providing content. * * - {@link Body}: An object that represents the body of a `Response`. * - `string`: A text-based representation of the body content. * - `Buffer`: A binary buffer containing the body data. * - `Uint8Array`: A byte array containing the body data in binary form. * - `Readable`: A Node.js Readable stream yielding Uint8Array chunks. * - `ReadableStream`: A web-standard ReadableStream. * - `null`: Represents an absent or empty body. * * String bodies will by default have a content-type of `text/plain`, while * byte-input like `Buffer` or `Readable` will default to * `application/octet-stream`. */ export type BodyLike = Body | string | Buffer | Uint8Array | Readable | ReadableStream | null; export declare const isBodyLike: (value: unknown) => value is BodyLike;