/** * The runtime request context (`c`): the `RawContext` implementation the handler receives, its lazy * `c.set` response-controls backing, and the bounded body readers behind `c.boundedBody`/`c.boundedJson`. * Type-imports the kernel's spine (never its values) and pulls its primitives from `runtime-core`, so it * sits below the server module in the graph. */ import type { RequestBudget } from "../budget.js"; import type { Platform } from "./context.js"; import type { ProtoPoisoning } from "./proto-guard.js"; import { CONTEXT_SEARCH, CONTEXT_SET } from "./runtime-core.js"; import type { CtxSet, RawContext, RequestSource } from "./server.js"; export { readBodyFramed, readBoundedJsonSource } from "./body-lane.js"; export declare class RequestContext implements RawContext { params: Record; body: unknown; private searchValue; private signalValue; private budgetValue; private platformValue; private setValue; private queryValue; private queryReady; private headersValue; private cookiesValue; private readonly source; private readonly maxBodyBytes; private readonly protoPoisoning; constructor(source: RequestSource, params: Record, maxBodyBytes: number, protoPoisoning?: ProtoPoisoning); constructor(source: RequestSource, params: Record, search: string | undefined, signal: AbortSignal, budget: RequestBudget, platform: Platform | undefined, maxBodyBytes: number, protoPoisoning?: ProtoPoisoning); /** * The no-timeout context: `c.signal`/`c.budget` fall back to the never-abort signal and the * unbounded budget, which is exactly what the request would have been handed, so the two slots * are left unwritten instead of initialized. `search` carries the router's already-split query * string when it has one; `undefined` leaves `c.query` to re-scan the URL lazily. */ static native(source: RequestSource, params: Record, search: string | undefined, maxBodyBytes: number, platform?: Platform, protoPoisoning?: ProtoPoisoning): RequestContext; [CONTEXT_SET](): CtxSet | undefined; get [CONTEXT_SEARCH](): string; get set(): CtxSet; get signal(): AbortSignal; get budget(): RequestBudget; get env(): unknown; get clientIp(): string | undefined; get waitUntil(): (promise: Promise) => void; get req(): Request; get request(): Request; header(name: string): string | null; get headers(): Record; set headers(value: Record); /** * Return a JSON body. Prefer this (and {@link text}) over a hand-rolled `return new Response(...)`: * on Node these helpers hand the adapter a status, a header record, and the bytes directly, so the * Web `Response` is deferred and the reply lands on the fastest write lane. A raw `new Response` is * fully supported and returns identical bytes, but it is the last-resort lane - the adapter has to * drain its body stream, which no direct-write helper pays. */ json(body: unknown, init?: ResponseInit | number): Response; /** * Return a text body. The fast lane on Node - see {@link json}. Reach for a raw `return new * Response(body)` only when you need a Response shape these helpers do not build; it costs the * adapter a body-stream drain that this path skips. */ text(body: string, init?: ResponseInit | number): Response; get query(): unknown; set query(v: unknown); get cookies(): Readonly>; boundedBody(maxBytes?: number): Promise; boundedJson(maxBytes?: number): Promise; } /** * Read a JSON body with the same byte cap used by schema validation and `c.boundedJson`, then * parse it through the prototype-poisoning guard (`protoPoisoning`, default `"reject"` - a * poisoned payload answers the same flat 400 as malformed JSON). Non-chunked, framed requests * with an in-cap `Content-Length` take the runtime's fused `json()` and walk the parsed value; * chunked or length-less requests fall back to the streaming byte-cap guard. */ //# sourceMappingURL=request-context.d.ts.map