import type { IncomingHttpHeaders, IncomingMessage, ServerResponse } from 'node:http'; import { type FrameworkRequest, type FrameworkRequestConnection, PayloadTooLargeException } from '@fluojs/http'; import type { MultipartOptions } from '@fluojs/runtime'; type MemoizedValue = () => T; type QueryRecord = Record; /** * Options for creating a deferred framework request shell from a Node-backed adapter. */ export interface DeferredFrameworkRequestShellOptions { cookieHeader?: string | string[] | undefined; connection?: FrameworkRequestConnection; headers?: FrameworkRequest['headers']; headersFactory?: () => FrameworkRequest['headers']; materializeBody?: () => Promise; method?: string; path: string; query?: QueryRecord; queryFactory?: () => QueryRecord; raw: RawRequest; requestId?: string; signal: AbortSignal | (() => AbortSignal); url: string; } /** * HTTP payload-size error that closes the underlying Node request stream after the response commits. */ export declare class NodeRequestPayloadTooLargeException extends PayloadTooLargeException { private readonly request; constructor(request: IncomingMessage); prepareResponse(response: ServerResponse): void; } /** * Creates a framework request from a raw Node incoming message. * * @param request - Raw Node request carrying headers, URL, and body stream. * @param signal - Abort signal tied to the response lifecycle. * @param multipartOptions - Multipart parser options applied to multipart requests. * @param maxBodySize - Maximum allowed non-multipart body size in bytes. * @param preserveRawBody - Whether to retain the raw request body bytes. * @returns The normalized framework request used by the dispatcher. */ export declare function createFrameworkRequest(request: IncomingMessage, signal: AbortSignal, multipartOptions?: MultipartOptions, maxBodySize?: number, preserveRawBody?: boolean): Promise; /** * Creates the cheap Node framework request shell before consuming the body stream. * * @param request - Raw Node request carrying headers, URL, and body stream. * @param signal - Abort signal tied to the response lifecycle. * @param multipartOptions - Multipart parser options applied when materializing multipart requests. * @param maxBodySize - Maximum allowed non-multipart body size in bytes. * @param preserveRawBody - Whether materialization should retain raw request body bytes. * @returns The framework request shell with metadata snapshotted and body materialization deferred. */ export declare function createDeferredFrameworkRequest(request: IncomingMessage, signal: AbortSignal, multipartOptions?: MultipartOptions, maxBodySize?: number, preserveRawBody?: boolean): FrameworkRequest; /** * Creates a framework request shell from already-snapshotted Node adapter metadata. * * @param options - Raw request, metadata factories, and deferred body materialization hooks. * @returns A framework request with lazy headers, cookies, query values, and optional body materialization. */ export declare function createDeferredFrameworkRequestShell({ cookieHeader, connection, headers, headersFactory, materializeBody, method, path, query, queryFactory, raw, requestId, signal, url, }: DeferredFrameworkRequestShellOptions): FrameworkRequest; /** * Materializes a deferred Node framework request body exactly once. * * @param request - Framework request returned by {@link createDeferredFrameworkRequest}. * @returns A promise that settles after body, rawBody, and files fields are populated when applicable. */ export declare function materializeFrameworkRequestBody(request: FrameworkRequest): Promise; /** * Creates a synchronous memoized value resolver. * * @param factory - Function that computes the value on first access. * @returns A stable resolver that returns the cached value after the first call. */ export declare function createMemoizedValue(factory: () => T): MemoizedValue; /** * Creates an async memoized side-effect resolver. * * @param factory - Async function to run at most once. * @returns A resolver that returns the same in-flight or completed promise for every call. */ export declare function createMemoizedAsyncValue(factory: () => Promise): () => Promise; /** * Creates an abort signal that fires when the Node response closes unexpectedly. * * @param response - Raw Node server response associated with the request. * @returns An abort signal for downstream request cancellation handling. */ export declare function createRequestSignal(response: ServerResponse): AbortSignal; /** * Resolves the request identifier from the preferred inbound headers. * * @param headers - Raw Node request headers. * @returns The request identifier when present. */ export declare function resolveRequestIdFromHeaders(headers: IncomingHttpHeaders): string | undefined; /** * Parses a raw URL search string into the framework query shape. * * @param search - Raw search string, with or without a leading question mark. * @returns Query values where repeated keys become string arrays. */ export declare function parseQueryParamsFromSearch(search: string): Record; /** * Snapshots host-parsed query values when they already match framework semantics. * * @param query - Host query object exposed by a Node-backed adapter. * @returns A cloned query record when all values are strings or string arrays; otherwise `undefined` for raw URL fallback. */ export declare function snapshotSimpleQueryRecord(query: unknown): QueryRecord | undefined; /** * Clones Node request headers into the framework header record shape. * * @param headers - Raw Node incoming headers. * @returns A shallow header snapshot with array values cloned. */ export declare function cloneRequestHeaders(headers: IncomingHttpHeaders): FrameworkRequest['headers']; /** * Clones a single Node header value when it is array-backed. * * @param value - Header value to snapshot. * @returns The original scalar value or a cloned array value. */ export declare function cloneHeaderValue(value: T): T; /** * Reads the primary value from a Node header value. * * @param headerValue - Header value that may contain multiple entries. * @returns The first header value when present. */ export declare function readPrimaryHeaderValue(headerValue: string | string[] | undefined): string | undefined; /** * Normalizes a Node content-type header to its primary media type. * * @param headerValue - Raw content-type header value. * @returns Lowercase primary media type without parameters, or `undefined` when absent. */ export declare function normalizePrimaryContentType(headerValue: string | string[] | undefined): string | undefined; /** * Parses a Node cookie header into framework cookie values. * * @param cookieHeader - Raw cookie header value or values. * @returns Cookie name/value pairs with percent-decoded values when possible. */ export declare function parseCookieHeader(cookieHeader: string | string[] | undefined): Record; /** * Splits a raw Node request URL into path and search components. * * @param rawUrl - Raw request URL, absolute URL, or undefined value from Node. * @returns The pathname and search string used by framework request matching and query parsing. */ export declare function splitRawRequestUrl(rawUrl: string | undefined): { path: string; search: string; }; /** * Resolves a raw Node request URL into an absolute URL string. * * @param rawUrl - Raw request URL, absolute URL, or undefined value from Node. * @returns An absolute URL suitable for Web-standard parsers. */ export declare function resolveAbsoluteRequestUrl(rawUrl: string | undefined): string; export {}; //# sourceMappingURL=internal-node-request.d.ts.map