import type { IncomingMessage } from "node:http"; import { type HttpResponseParts, TO_HTTP_RESPONSE_PARTS, type ToHttpResponseParts } from "./to-response-parts.js"; /** * Represents a case-insensitive map for HTTP headers. * * Allows insertion, appending, removal, clearing, and extending of key-value * pairs. */ export declare class HeaderMap implements ToHttpResponseParts { protected readonly map: Map; /** * Creates a new {@link HeaderMap}. * * You can optionally provide entries to initialize the map with existing * key-value pairs. **/ constructor(entries?: Iterable | HeaderMap); /** * Create a new {@link HeaderMap} from an `Iterable` of key-value pairs. * * This allows you to create the map from string values instead of * `HeaderValue`s. */ static from(entries: Iterable): HeaderMap; /** * Creates a new {@link HeaderMap} from the provided {@link IncomingMessage}. * * Converts the headers of the IncomingMessage into a map structure that can * be used by the HeaderMap. */ static fromIncomingMessage(message: IncomingMessage): HeaderMap; /** * Determines whether the map contains no elements. */ isEmpty(): boolean; /** * Returns the number of elements in the map. */ len(): number; /** * Checks if the given key exists in the map. */ containsKey(key: string): boolean; /** * Retrieves the first value associated with the specified key. */ get(key: string): HeaderValue | null; /** * Retrieves all values associated with the provided key. */ getAll(key: string): readonly HeaderValue[]; /** * Retrieves an iterator that allows iteration over all the keys in the map. */ keys(): IterableIterator; /** * Returns an iterator that yields all values stored in the internal map. * * The values are yielded sequentially from the inner collections. */ values(): IterableIterator; /** * Returns an iterator of key-value pairs where keys and values are strings. * * Each key may correspond to multiple values, and the iterator yields each * key-value pair individually. */ entries(): IterableIterator; [Symbol.iterator](): IterableIterator; /** * Inserts a key-value pair into the map. * * If one or more values already exist for the key, they are replaced with * the new value. */ insert(key: string, value: HeaderValueLike): void; /** * Appends a value to the list of values associated with the specified key. * * If the key does not exist, it initializes a new list and adds the value * to it. */ append(key: string, value: HeaderValueLike): void; /** * Removes the entry associated with the specified key from the map. */ remove(key: string): HeaderValue | null; /** * Clears the entire map. */ clear(): void; /** * Extends the map by inserting key-value pairs from the given iterable. * * Values in the iterable will overwrite existing values for the same key. */ extend(items: Iterable): void; toJSON(): Record; [TO_HTTP_RESPONSE_PARTS](res: HttpResponseParts): void; } /** * Represents a single value in an HTTP header. * * Some header values may be sensitive and should not be logged or displayed. * You can mark headers as sensitive by calling `setSensitive(true)`. This will * prevent the value from being exposed to loggers. */ export declare class HeaderValue { readonly value: string; private sensitive; /** * Creates a new {@link HeaderValue}. */ constructor(value: string, sensitive?: boolean); /** * Marks the header value as sensitive. */ setSensitive(sensitive: boolean): this; /** * Checks if the header value is sensitive. */ isSensitive(): boolean; toJSON(): string; } export type HeaderValueLike = HeaderValue | string; export type HeaderEntryLike = [name: string, value: HeaderValueLike]; export type HeaderEntry = [name: string, value: HeaderValue];