StaticcoerceConverts various header formats to HttpHeader instance.
Accepts Headers, arrays, objects, or existing HttpHeader instances. Automatically handles comma-separated values and normalizes header names.
Headers in any supported format
HttpHeader instance
StaticfromCreates HttpHeader by merging multiple header sources.
One or more header sources to merge
New HttpHeader with all headers merged
Gets all values for a header (case-insensitive).
Header name
Array of all values for the header
Gets the first value for a header (case-insensitive).
Header name
First value or undefined if not present
Sets a header, replacing any existing values.
Header name
Single value or array of values
This HttpHeader instance for chaining
Adds value(s) to a header, preserving existing values.
Header name
Single value, array of values, or undefined
This HttpHeader instance for chaining
Deletes a header.
Header name to delete
This HttpHeader instance for chaining
Returns all headers as key-value array pairs.
Each entry is a tuple of [headerName, values[]] where headerName is lowercase and values is an array of all values for that header. Headers with no values are excluded.
Array of [name, values] tuples
Returns all headers as sorted key-value array pairs.
Same as Items() but sorted alphabetically by header name.
Array of [name, values] tuples sorted by name
Creates a deep copy of the HttpHeader instance.
New HttpHeader with the same headers
Converts headers to a plain object with string array values.
Each header name maps to an array of all its values. Useful for serialization or when working with APIs that expect this format.
Object with header names as keys and string arrays as values
Converts headers to a plain object with comma-separated string values.
Multiple values for the same header are joined with ", ". Useful for compatibility with APIs that expect single string values per header.
Object with header names as keys and comma-separated strings as values
Converts headers to HeadersInit format with only first value per header.
Only the first value is used when multiple values exist for a header. Needed for Cloudflare Workers' HeadersInit type compatibility.
HeadersInit type (for type compatibility)
Object compatible with HeadersInit
Converts to native Headers implementation.
Multiple values are joined with ", " as per HTTP spec.
HeadersImpl instance compatible with standard Headers interface
Merges other headers into this instance (in-place mutation).
Adds all headers from the provided sources to this instance. If headers already exist, values are added (not replaced).
One or more header sources to merge
This HttpHeader instance for chaining
Merges other headers, returning a new instance.
Creates a clone of this instance and merges the provided headers into it. The original instance remains unchanged.
One or more header sources to merge
New HttpHeader with merged headers
HTTP header container with multi-value support and type-safe operations.
HttpHeader provides a comprehensive API for managing HTTP headers with support for multiple values per header name. All header names are normalized to lowercase for case-insensitive comparison. Supports conversion to/from various formats including native Headers, plain objects, and arrays.
Example