import type { IncomingMessage } from "node:http"; import { SocketAddress } from "node:net"; import { Body, type BodyLike } from "./body.js"; import { type ExtensionKey, Extensions } from "./extensions.js"; import { HeaderMap, type HeaderValueLike } from "./headers.js"; import { Method } from "./method.js"; /** * Represents the components of an HTTP request, encapsulating method, URI, * version, headers, and optional extensions. */ export declare class Parts { readonly method: Method; readonly uri: URL; readonly version: string; readonly headers: HeaderMap; readonly extensions: Extensions; /** * Creates a new {@link Parts}. */ constructor(method: Method, uri: URL, version: string, headers: HeaderMap, extensions?: Extensions); /** * Creates a new {@link Parts} with the provided URI. */ withUri(uri: URL): Parts; /** * Creates a new {@link Parts} from the provided {@link IncomingMessage}. * * If `trustProxy` is `true`, the `X-Forwarded-Proto` and `X-Forwarded-Host` * headers will be used to determine the protocol and host of the request. * * Otherwise, the protocol and host will be determined from the * `IncomingMessage`. */ static fromIncomingMessage(message: IncomingMessage, trustProxy: boolean): Parts; } /** * Represents an HTTP request, encapsulating the request's headers, body, and * associated metadata such as the HTTP method, URI, and version. */ export declare class HttpRequest { readonly head: Parts; readonly body: Body; readonly connectInfo: SocketAddress; /** * Creates a new {@link HttpRequest}. */ constructor(head: Parts, body: Body, connectInfo?: SocketAddress); /** * Creates a new {@link HttpRequestBuilder}. */ static builder(): HttpRequestBuilder; /** * Creates a new {@link HttpRequest} from the provided {@link IncomingMessage}. * * @see {@link Parts.fromIncomingMessage} for more information about the `trustProxy` * parameter. */ static fromIncomingMessage(message: IncomingMessage, trustProxy: boolean): HttpRequest; /** * Creates a new {@link HttpRequest} with the provided body. */ withBody(body: Body): HttpRequest; /** * Creates a new {@link HttpRequest} with the provided URI. */ withUri(uri: URL): HttpRequest; get method(): Method; get uri(): URL; get version(): string; get headers(): HeaderMap; get extensions(): Extensions; toJSON(): Record; } /** * Builder for creating HTTP requests. */ export declare class HttpRequestBuilder { private method_; private uri_; private version_; private headers_; private extensions_; private connectInfo_; method(method: Method | string): this; uri(uri: URL): this; path(path: string): this; version(version: string): this; headers(headers: HeaderMap): this; header(key: string, value: HeaderValueLike): this; extensions(extensions: Extensions): this; extension(key: ExtensionKey, value: T): this; connectInfo(connectInfo: SocketAddress): this; body(body: BodyLike): HttpRequest; }