HttpHeaders class

A collection of HTTP header key/value pairs.

Constructors

HttpHeaders(RawHttpHeaders)

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.

toString()

Get the string representation of this HTTP header collection.

Constructor Details

HttpHeaders(RawHttpHeaders)

new HttpHeaders(rawHeaders?: RawHttpHeaders)

Parameters

rawHeaders
RawHttpHeaders

Method Details

clone()

Create a deep clone/copy of this HttpHeaders collection.

function clone(): HttpHeaders

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.

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

Parameters

options

{ preserveCase?: boolean }

Returns

toString()

Get the string representation of this HTTP header collection.

function toString(): string

Returns

string