HttpHeaders

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

Immutable set of Http headers, with lazy parsing.

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

可选. 默认值是 undefined.

方法

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

Checks for existence of header by given name.

has(name: string): boolean
      
      has(name: string): boolean
    
参数
name string
返回值

boolean

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

Returns first header that matches given name.

get(name: string): string | null
      
      get(name: string): string | null
    
参数
name string
返回值

string | null

返回头中所有的名称。

Returns the names of the headers

keys(): string[]
      
      keys(): string[]
    
参数

没有参数。

返回值

string[]

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

Returns list of header values for a given name.

getAll(name: string): string[] | null
      
      getAll(name: string): string[] | null
    
参数
name string
返回值

string[] | null

append(name: string, value: string | string[]): HttpHeaders
      
      append(name: string, value: string | string[]): HttpHeaders
    
参数
name string
value string | string[]
返回值

HttpHeaders

set(name: string, value: string | string[]): HttpHeaders
      
      set(name: string, value: string | string[]): HttpHeaders
    
参数
name string
value string | string[]
返回值

HttpHeaders

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

可选. 默认值是 undefined.

返回值

HttpHeaders