HttpHeadersLike interface

A collection of HTTP header key/value pairs.

Methods

clone()

Create a deep clone/copy of this HttpHeaders collection.

contains(string)

Get whether or not this header collection contains a header entry for the provided header name.

get(string)

Get the header value for the provided header name, or undefined if no header exists in this collection with the provided name.

headerNames()

Get the header names that are contained in this collection.

headersArray()

Get the headers that are contained in this collection as an array.

headerValues()

Get the header values that are contained in this collection.

rawHeaders()

Get the headers that are contained this collection as an object.

remove(string)

Remove the header with the provided headerName. Return whether or not the header existed and was removed.

set(string, string | number)

Set a header in this collection with the provided name and value. The name is case-insensitive.

toJson({ preserveCase?: boolean })

Get the JSON object representation of this HTTP header collection. The result is the same as rawHeaders().

Method Details

clone()

Create a deep clone/copy of this HttpHeaders collection.

function clone(): HttpHeadersLike

Returns

contains(string)

Get whether or not this header collection contains a header entry for the provided header name.

function contains(headerName: string): boolean

Parameters

headerName

string

Returns

boolean

get(string)

Get the header value for the provided header name, or undefined if no header exists in this collection with the provided name.

function get(headerName: string): undefined | string

Parameters

headerName

string

The name of the header.

Returns

undefined | string

headerNames()

Get the header names that are contained in this collection.

function headerNames(): string[]

Returns

string[]

headersArray()

Get the headers that are contained in this collection as an array.

function headersArray(): HttpHeader[]

Returns

headerValues()

Get the header values that are contained in this collection.

function headerValues(): string[]

Returns

string[]

rawHeaders()

Get the headers that are contained this collection as an object.

function rawHeaders(): RawHttpHeaders

Returns

remove(string)

Remove the header with the provided headerName. Return whether or not the header existed and was removed.

function remove(headerName: string): boolean

Parameters

headerName

string

The name of the header to remove.

Returns

boolean

set(string, string | number)

Set a header in this collection with the provided name and value. The name is case-insensitive.

function set(headerName: string, headerValue: string | number)

Parameters

headerName

string

The name of the header to set. This value is case-insensitive.

headerValue

string | number

The value of the header to set.

toJson({ preserveCase?: boolean })

Get the JSON object representation of this HTTP header collection. The result is the same as rawHeaders().

function toJson(options?: { preserveCase?: boolean }): RawHttpHeaders

Parameters

options

{ preserveCase?: boolean }

Returns