你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

HttpHeaders class

HTTP 标头键/值对的集合。

构造函数

HttpHeaders(RawHttpHeaders)

方法

clone()

创建此 HttpHeaders 集合的深层克隆/副本。

contains(string)

获取此标头集合是否包含提供的标头名称的标头条目。

get(string)

获取提供的标头名称的标头值;如果此集合中不存在具有所提供的名称的标头,则获取未定义。

headerNames()

获取此集合中包含的标头名称。

headersArray()

获取此集合中包含的标头作为数组。

headerValues()

获取此集合中包含的标头值。

rawHeaders()

获取作为 对象包含此集合的标头。

remove(string)

使用提供的 headerName 删除标头。 返回标头是否存在且是否已删除。

set(string, string | number)

在此集合中,使用提供的名称和值设置标头。 该名称不区分大小写。

toJson({ preserveCase?: boolean })

获取此 HTTP 标头集合的 JSON 对象表示形式。

toString()

获取此 HTTP 标头集合的字符串表示形式。

构造函数详细信息

HttpHeaders(RawHttpHeaders)

new HttpHeaders(rawHeaders?: RawHttpHeaders)

参数

rawHeaders
RawHttpHeaders

方法详细信息

clone()

创建此 HttpHeaders 集合的深层克隆/副本。

function clone(): HttpHeaders

返回

contains(string)

获取此标头集合是否包含提供的标头名称的标头条目。

function contains(headerName: string): boolean

参数

headerName

string

返回

boolean

get(string)

获取提供的标头名称的标头值;如果此集合中不存在具有所提供的名称的标头,则获取未定义。

function get(headerName: string): undefined | string

参数

headerName

string

标头的名称。

返回

undefined | string

headerNames()

获取此集合中包含的标头名称。

function headerNames(): string[]

返回

string[]

headersArray()

获取此集合中包含的标头作为数组。

function headersArray(): HttpHeader[]

返回

headerValues()

获取此集合中包含的标头值。

function headerValues(): string[]

返回

string[]

rawHeaders()

获取作为 对象包含此集合的标头。

function rawHeaders(): RawHttpHeaders

返回

remove(string)

使用提供的 headerName 删除标头。 返回标头是否存在且是否已删除。

function remove(headerName: string): boolean

参数

headerName

string

要删除的标头的名称。

返回

boolean

set(string, string | number)

在此集合中,使用提供的名称和值设置标头。 该名称不区分大小写。

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

参数

headerName

string

要设置的标头名称。 此值不区分大小写。

headerValue

string | number

要设置的标头的值。

toJson({ preserveCase?: boolean })

获取此 HTTP 标头集合的 JSON 对象表示形式。

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

参数

options

{ preserveCase?: boolean }

返回

toString()

获取此 HTTP 标头集合的字符串表示形式。

function toString(): string

返回

string