/** * Copyright (c) 2026 AzerothJS. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ /** * @internal The shared constructor: declare the exact Content-Length, and return the * kernel's lazy Response (see payload.ts) - adapters write it with a plain writeHead + end, * no web-stream, no undici, and no JS-side encoding on the hot path. */ export declare function payloadResponse(body: string, contentType: string, init: ResponseInit): Response; /** A JSON response; the default for API handlers. */ export declare function json(data: unknown, init?: ResponseInit): Response; /** A plain-text response. */ export declare function text(body: string, init?: ResponseInit): Response; /** An HTML response (what an SSR route returns). */ export declare function html(body: string, init?: ResponseInit): Response; /** * A redirect. Defaults to 303 (See Other) rather than 302: after a POST, 303 is the one * status every client agrees turns the follow-up into a GET - the post/redirect/get idiom * working as intended. Pass 301/302/307/308 explicitly when semantics differ. * * `init` exists because a redirect routinely carries a cookie: sign-out is "expire the session * AND redirect", and a logout that redirects without clearing the cookie leaves the user signed * in. Built through the kernel's response so every `Set-Cookie` survives - header iteration * collapses duplicates, and only `getSetCookie()` preserves a session and a CSRF cookie together. * * @param location - The `Location` header value. * @param status - The redirect status; 303 by default. * @param init - Extra headers, most often `Set-Cookie`. * @returns A bodyless redirect response. * @example * app.post('/sign-out', () => redirect('/login', 303, { * headers: { 'set-cookie': expireCookie('session') } * })); */ export declare function redirect(location: string, status?: 301 | 302 | 303 | 307 | 308, init?: ResponseInit): Response; /** * 204: success with nothing to say (the correct DELETE response). * * Built through the kernel's response like every other constructor, so it takes the adapter's * writeHead+end fast path and can carry a `Set-Cookie`. `payloadResponse` drops the body, * `Content-Length` and `Content-Type` for a 204 per RFC 9112 section 6.2 - declaring a length * with no body on a keep-alive connection is the shape a framing desync is built from. * * @param init - Extra headers. * @returns A 204 with no body. */ export declare function noContent(init?: ResponseInit): Response; /** 201 with a Location header; `data` (when given) is the created representation as JSON. */ export declare function created(location: string, data?: unknown): Response;