Documentation
    Preparing search index...

    Type Alias Headerify<T>

    Headerify: {
        [P in keyof T]?: T[P] extends HeaderValue
        | undefined
            ? P extends string
                ? Lowercase<P> extends "set-cookie"
                    ? Exclude<T[P], undefined> extends HeaderValue[]
                        ? T[P] | undefined
                        : never
                    : Lowercase<P> extends
                        | "age"
                        | "authorization"
                        | "content-length"
                        | "content-type"
                        | "etag"
                        | "expires"
                        | "from"
                        | "host"
                        | "if-modified-since"
                        | "if-unmodified-since"
                        | "last-modified"
                        | "location"
                        | "max-forwards"
                        | "proxy-authorization"
                        | "referer"
                        | "retry-after"
                        | "server"
                        | "user-agent"
                        ? Extract<Exclude<T[P], undefined>, HeaderValue[]> extends never
                            ? T[P] | undefined
                            : never
                        : T[P] | undefined
                : never
            : never
    }

    Type of headers

    Headerify removes every properties that are not allowed in the HTTP headers type.

    Below are list of prohibited in HTTP headers.

    1. Value type is neither HeaderValue nor omitted undefined
    2. Key is "set-cookie", but value is not an Array type
    3. Key is one of them, but value is Array type
    • "age"
    • "authorization"
    • "content-length"
    • "content-type"
    • "etag"
    • "expires"
    • "from"
    • "host"
    • "if-modified-since"
    • "if-unmodified-since"
    • "last-modified"
    • "location"
    • "max-forwards"
    • "proxy-authorization"
    • "referer"
    • "retry-after"
    • "server"
    • "user-agent"

    Type Parameters

    • T extends object | undefined

    contracts/common.md#principled-implementation Each key admits only HeaderValue or omitted undefined. Classifying the defined value domain preserves optional array set-cookie inputs; singleton headers reject any array member even in a scalar/array union. An undefined-only domain transmits nothing and stays permitted. Lowercase keys follow HTTP's case-insensitive names, and ordinary keys retain their type.

    contracts/common.md#clear-and-simple-design One mapped type that rejects an entry by turning it into never, with the rule spelled out in the comment.

    contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.

    contracts/common.md#meaningful-documentation The comment lists the prohibited cases and the singleton headers.