/** * The head of a plaintext HTTP/1 request, read for where it was going: the * `Host` header, or the authority of an absolute-form target, which a * transparent interceptor has no other way to learn once the destination * address has been rewritten to it. It reads the request line and the header * names and values only as far as `Host`, keeps nothing, and refuses a head * that two parsers could read differently (a repeated `Host`, a target that * disagrees with it, a line the grammar does not allow) rather than choose. * * RFC 9112 sections 3 (request line), 3.2 (request target) and 5 (field * syntax); RFC 9110 section 7.2 (Host). */ /** The reading of a client's first bytes as HTTP/1. */ export type RequestHeadReading = /** The bytes are an HTTP request whose head has not fully arrived. */ { readonly kind: "NEED_MORE"; } /** The bytes are not an HTTP/1 request. */ | { readonly kind: "NOT_HTTP"; } /** An HTTP/1 request whose destination cannot be placed with certainty. */ | { readonly kind: "MALFORMED"; readonly reason: RequestHeadRefusal; } | { readonly kind: "REQUEST"; readonly method: string; /** The path and query, as sent. */ readonly target: string; readonly host: string; /** The port the authority named; null when it named none. */ readonly port: number | null; }; export type RequestHeadRefusal = "REQUEST_LINE_INVALID" | "HOST_MISSING" | "HOST_REPEATED" | "HOST_INVALID" | "TARGET_INVALID" | "TARGET_DISAGREES_WITH_HOST" | "HEADER_INVALID" | "HEAD_TOO_LONG"; /** The most head bytes read before a request is refused as too long to place. */ export declare const MAX_REQUEST_HEAD_BYTES = 16384; /** Reads a client's first bytes as an HTTP/1 request head, or says why they are not one. */ export declare function readRequestHead(bytes: Uint8Array): RequestHeadReading; interface Authority { readonly host: string; readonly port: number | null; } /** `host[:port]`, with the host a name, an IPv4 address or a bracketed IPv6 address, lowercased. */ export declare function parseAuthority(value: string): Authority | null; export {}; //# sourceMappingURL=RequestHead.d.ts.map