HttpHeaders

class

Immutable set of Http headers, with lazy parsing.

class HttpHeaders {
  constructor(headers?: string | {...})
  has(name: string): boolean
  get(name: string): string | null
  keys(): string[]
  getAll(name: string): string[] | null
  append(name: string, value: string | string[]): HttpHeaders
  set(name: string, value: string | string[]): HttpHeaders
  delete(name: string, value?: string | string[]): HttpHeaders
}

Constructor

constructor(headers?: string | { [name: string]: string | string[]; })

Parameters

headers

Type: string | { [name: string]: string | string[]; }.

Optional. Default is undefined.

Methods

Checks for existence of header by given name.

has(name: string): boolean

Parameters

name

Type: string.

Returns

boolean

Returns first header that matches given name.

get(name: string): string | null

Parameters

name

Type: string.

Returns

string | null

Returns the names of the headers

keys(): string[]

Parameters

There are no parameters.

Returns

string[]

Returns list of header values for a given name.

getAll(name: string): string[] | null

Parameters

name

Type: string.

Returns

string[] | null

append(name: string, value: string | string[]): HttpHeaders

Parameters

name

Type: string.

value

Type: string | string[].

Returns

HttpHeaders

set(name: string, value: string | string[]): HttpHeaders

Parameters

name

Type: string.

value

Type: string | string[].

Returns

HttpHeaders

delete(name: string, value?: string | string[]): HttpHeaders

Parameters

name

Type: string.

value

Type: string | string[].

Optional. Default is undefined.

Returns

HttpHeaders

© 2010–2019 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v6.angular.io/api/common/http/HttpHeaders