import type { CookieOptions, SendFileOptions } from "../types"; import type { BunRequest } from "./request"; export interface RenderOptions { [key: string]: unknown; } export interface AppContext { get(setting: string): unknown; getEngine(ext: string): ((path: string, options: Record, callback: (err: Error | null, html?: string) => void) => void) | undefined; locals: Record; } export type FormatHandlers = { [contentType: string]: (() => void) | undefined; }; export declare class BunResponse { private _statusCode; private _headersMap; private _multiHeaders; private _body; private _sent; private _app?; private _acceptHeader?; private _req?; _compressionEncoding: string | null; _compressionThreshold: number; _compressionLevel: number; _compressionFilter: ((contentType: string) => boolean) | null; private _streaming; private _streamController; private _streamPromise; private _headersFlushed; locals: Record; private headersMap; private multiHeaders; private headerKey; private hasHeader; private toHeaders; setApp(app: AppContext): void; setAcceptHeader(accept: string | undefined): void; setReq(req: BunRequest): void; get req(): BunRequest | undefined; get app(): AppContext | undefined; get statusCode(): number; get headersSent(): boolean; status(code: number): this; set(name: string | Record, value?: string): this; header(name: string | Record, value?: string): this; get(name: string): string | undefined; getHeader(name: string): string | undefined; append(name: string, value: string): this; type(mimeType: string): this; contentType(type: string): this; vary(field: string | string[]): this; location(url: string): this; links(links: Record): this; attachment(filename?: string): this; json(data: unknown): this; jsonp(data: unknown): void; send(body?: unknown): this; text(data: string): void; html(data: string): void; sendStatus(code: number): void; format(handlers: FormatHandlers): void; redirect(urlOrStatus: string | number, url?: string): void; cookie(name: string, value: string | Record, options?: CookieOptions): this; clearCookie(name: string, options?: CookieOptions): this; sendFile(filePath: string, options?: SendFileOptions): Promise; sendFile(filePath: string, callback: (err?: Error) => void): Promise; sendFile(filePath: string, options: SendFileOptions, callback: (err?: Error) => void): Promise; download(filePath: string, filename?: string, options?: SendFileOptions | ((err?: Error) => void), callback?: (err?: Error) => void): Promise; ok(data?: unknown): void; created(data?: unknown): void; noContent(): void; badRequest(message?: string): void; unauthorized(message?: string): void; forbidden(message?: string): void; notFound(message?: string): void; /** * Initialize streaming mode and return the stream for the response. * Call this internally when write() is first called. */ private _initStream; /** * Write a chunk to the response stream (Express-compatible). * This enables streaming responses for large data. * * @example * app.get('/stream', (req, res) => { * res.set('Content-Type', 'text/plain'); * res.write('Hello '); * res.write('World'); * res.end('!'); * }); */ write(chunk: string | Uint8Array | ArrayBuffer): boolean; /** * End the response stream (Express-compatible). * Optionally write final data before closing. * * @example * res.end(); // Just close * res.end('Final chunk'); // Write and close */ end(chunk?: string | Uint8Array | ArrayBuffer, encoding?: string | (() => void), callback?: () => void): void; /** * Flush the response headers immediately (Express-compatible). * Useful for SSE or when you want headers sent before body. */ flushHeaders(): void; /** * Check if response is in streaming mode */ isStreaming(): boolean; /** * Get the stream promise for streaming responses */ getStream(): Promise> | null; toResponse(): Response; /** * Create a streaming response. Used internally by the router. */ toStreamingResponse(): Promise; getHeaders(): Headers; isSent(): boolean; render(view: string, options?: RenderOptions, callback?: (err: Error | null, html?: string) => void): Promise; } //# sourceMappingURL=response.d.ts.map