HttpHeaders

Immutable set of Http headers, with lazy parsing.

Http 头的不可变集合,惰性解析。

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(headers?: string | { [name: string]: string | string[]; })

参数

headers

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

可选. 默认值是 undefined.

方法

Checks for existence of header by given name.

检查是否存在指定名称的头。

has(name: string): boolean

参数

name

Type: string.

返回值

boolean

Returns first header that matches given name.

返回匹配指定名称的第一个头的值。

get(name: string): string | null

参数

name

Type: string.

返回值

string | null

Returns the names of the headers

返回头中所有的名称。

keys(): string[]

参数

没有参数。

返回值

string[]

Returns list of header values for a given name.

返回头中具有指定名称的值的列表。

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

参数

name

Type: string.

返回值

string[] | null

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

参数

name

Type: string.

value

Type: string | string[].

返回值

HttpHeaders

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

参数

name

Type: string.

value

Type: string | string[].

返回值

HttpHeaders

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

参数

name

Type: string.

value

Type: string | string[].

可选. 默认值是 undefined.

返回值

HttpHeaders