• Overview
@angular/common/http

HttpHeaders

Class
stable

Represents the header configuration options for an HTTP request. Instances are immutable. Modifying methods return a cloned instance with the change. The original object is never changed.

API

    
      class HttpHeaders {}
    
    

constructor

HttpHeaders

Constructs a new HTTP header object with the given values.

@paramheadersstring | { [name: string]: string | number | (string | number)[]; } | Headers | undefined
@returnsHttpHeaders

has

boolean

Checks for existence of a given header.

@paramnamestring

The header name to check for existence.

@returnsboolean

True if the header exists, false otherwise.

get

string | null

Retrieves the first value of a given header.

@paramnamestring

The header name.

@returnsstring | null

The value string if the header exists, null otherwise

keys

string[]

Retrieves the names of the headers.

@returnsstring[]

A list of header names.

getAll

string[] | null

Retrieves a list of values for a given header.

@paramnamestring

The header name from which to retrieve values.

@returnsstring[] | null

A string of values if the header exists, null otherwise.

append

HttpHeaders

Appends a new value to the existing set of values for a header and returns them in a clone of the original instance.

@paramnamestring

The header name for which to append the values.

@paramvaluestring | string[]

The value to append.

@returnsHttpHeaders

A clone of the HTTP headers object with the value appended to the given header.

set

HttpHeaders

Sets or modifies a value for a given header in a clone of the original instance. If the header already exists, its value is replaced with the given value in the returned object.

@paramnamestring

The header name.

@paramvaluestring | string[]

The value or values to set or override for the given header.

@returnsHttpHeaders

A clone of the HTTP headers object with the newly set header value.

delete

HttpHeaders

Deletes values for a given header in a clone of the original instance.

@paramnamestring

The header name.

@paramvaluestring | string[] | undefined

The value or values to delete for the given header.

@returnsHttpHeaders

A clone of the HTTP headers object with the given value deleted.

Jump to details