import fs from 'node:fs'; import nodeStream from 'node:stream'; import { EventEmitter } from 'events'; import { LocalFile } from '../impl/local-file.js'; import type { HttpIncoming } from '../interfaces/http-incoming.interface.js'; /** * * @namespace BodyReader */ export declare namespace BodyReader { interface Options { limit?: number | string; toFile?: boolean | string; } } type Callback = (...args: any[]) => any; /** * BodyReader is responsible for reading and parsing the request body. * It supports various content encodings and can save the body to a file. */ export declare class BodyReader extends EventEmitter { readonly req: HttpIncoming; limit?: number; protected _stream?: nodeStream.Readable; protected _buffer?: string | Buffer[]; protected _completed?: boolean | undefined; protected _receivedSize: number; protected _file?: LocalFile; protected _fileStream?: fs.WriteStream; protected cleanup: Callback; protected onAborted: Callback; protected onData: Callback; protected onEnd: Callback; constructor(req: HttpIncoming, options?: BodyReader.Options); /** * Reads the request body. * * @returns A promise that resolves to the body content (string, Buffer, or LocalFile). * @throws {@link InternalServerError} If the stream is already read or not readable. * @throws {@link OpraHttpError} If the content size exceeds the limit. */ read(): Promise | undefined>; protected _onEnd(error: any): void; protected _cleanup(): void; protected _onAborted(): void; protected _onData(chunk: Buffer | string): void; /** * Static method to read the request body. * * @param req - The incoming HTTP request. * @param options - Optional reader settings. * @returns A promise that resolves to the body content. */ static read(req: HttpIncoming, options?: BodyReader.Options): Promise; protected static encoderPipeline(req: HttpIncoming): nodeStream.Readable; } export {};