Optionalinit: HeadersInit | Record<string, string | string[]> | HttpHeaders | nullOptional initial headers (WHATWG Headers, HttpHeaders,
plain object, or [name, value][] array)
Guard mode (default: "none")
The string tag "HttpHeaders"
Number of distinct header names.
Get the parsed Content-Type header value.
Set the Content-Type header from a string or parsed value.
Get the Content-Length header value as a number.
Set the Content-Length header from a number.
Get the parsed Content-Disposition header value.
Set the Content-Disposition header from a string or parsed value.
Get the parsed Cache-Control header directives.
Set the Cache-Control header from a string or partial directives.
Get the parsed Authorization header credentials.
Set the Authorization header from a raw string.
Parsed Accept quality values sorted by q-factor
Parsed Accept-Encoding quality values sorted by q-factor
Parsed Accept-Language quality values sorted by q-factor
Parsed Range request header (RFC 7233)
Parsed Content-Range response header (RFC 7233)
Get the ETag header value.
Set the ETag header, automatically quoting if needed.
Get parsed Link header entries.
Get the parsed Retry-After header value.
Get the parsed Strict-Transport-Security header value.
Set the Strict-Transport-Security header from an HSTS value.
Get the parsed Content-Security-Policy directives.
Set the Content-Security-Policy header from a string or directive map.
Get parsed Server-Timing entries.
Best guess at real client IP from Forwarded / X-Forwarded-For / X-Real-IP
Normalized Forwarded or X-Forwarded-* information
Raw Host header value
Raw Origin header value
Raw User-Agent header value
Raw Location header value
Parsed Date header as a Date object
Parsed Age header in seconds
Parsed Vary header as an array of field names (lowercased)
X-Request-ID header value
X-Correlation-ID header value
X-Powered-By header value
X-Requested-With header value
X-RateLimit-Limit header value (parsed as number)
X-RateLimit-Remaining header value (parsed as number)
X-RateLimit-Reset header value (parsed as number)
Sec-Fetch-Site header value
Sec-Fetch-Mode header value
Sec-Fetch-User header value
Sec-Fetch-Dest header value
Early-Data header value (parsed as number)
Priority header value
Allow header value
Server header value
Accept-Ranges header value
Parsed Last-Modified header as a Date object
Parsed Expires header as a Date object
Content-Encoding header value
Content-Language header value
Content-Location header value
First Link header entry (parsed)
Parsed Alt-Svc entries
Get parsed WWW-Authenticate challenge entries.
Set the WWW-Authenticate header from challenge entries.
Get parsed Proxy-Authenticate challenge entries.
Set the Proxy-Authenticate header from challenge entries.
Get the parsed Proxy-Authorization header credentials.
Set the Proxy-Authorization header from a string or parsed credentials.
Get all Set-Cookie header values as an array.
Access-Control-Allow-Origin header value
Access-Control-Allow-Methods header value
Access-Control-Allow-Headers header value
Access-Control-Max-Age header value (parsed as number)
Access-Control-Allow-Credentials header value (parsed as boolean)
Append a value to an existing header (or create it). Unlike set, this does NOT overwrite existing values.
Header name (case-insensitive)
Header value (leading/trailing OWS stripped)
Return the combined value of a header. Multiple values are joined with ", " except for Set-Cookie / WWW-Authenticate / Proxy-Authenticate, which return only the first value.
Header name (case-insensitive)
The combined header value, or null if absent
Return all values for a header as an array (useful for Set-Cookie).
Header name (case-insensitive)
Array of values (empty if absent)
Check if a header exists.
Header name (case-insensitive)
true if the header is set
Execute a callback for each header entry. Multi-value headers are joined with ", " for the callback, except for Set-Cookie (each value is called separately).
Called once per combined value with (value, name, headers)
OptionalthisArg: unknownValue for this inside the callback
Iterator over all header names (lowercased).
Iterator over all header values. Multi-value headers are joined with ", " except Set-Cookie.
Iterator over [name, value] tuples (WHATWG Headers-compatible).
Convert to a plain object. Multi-value headers become arrays.
Convert to a flat object. Multi-value headers are joined with ", ".
Serialize as HTTP/1.1 header block (CRLF-delimited).
Return a new immutable copy.
Merge another headers source into this one.
Existing values are overwritten unless append is true.
Return a new HttpHeaders containing only the listed header names.
Return a new HttpHeaders without the listed header names.
Redact sensitive header values (replace with "REDACTED"). Useful for logging.
Returns headers present in other that differ from this instance
(by combined value). Useful for diffing request/response headers.
RichHeaders extends HttpHeaders with typed getter/setter shortcuts for all commonly-used headers.
Provides parsed accessors for:
Example