Options
All
  • Public
  • Public/Protected
  • All
Menu

Represents a modifiable map of HTTP headers.

see

https://fetch.spec.whatwg.org/#headers-class

Hierarchy

  • Headers

Index

Constructors

constructor

  • Constructs a new header map.

    Optionally initialization data can be passed in.

    Parameters

    • Optional init: HeadersInit

      Optional header initialization data, will be cloned.

    Returns Headers

Accessors

length

  • get length(): number
  • Returns how many headers there are.

    Returns number

Methods

[Symbol.iterator]

  • [Symbol.iterator](): IterableIterator<[string, string]>
  • Returns an iterator over all the headers that have been inserted.

    Returns IterableIterator<[string, string]>

append

  • append(name: string, value: string): void
  • Appends a header to the map. If there already is a header with the given name, the value will be appended.

    Parameters

    • name: string

      The name of the header to append.

    • value: string

      The header value.

    Returns void

delete

  • delete(name: string): void
  • Deletes all headers with the given name from the map.

    Parameters

    • name: string

      The name of the headers to delete.

    Returns void

entries

  • entries(): IterableIterator<[string, string]>
  • Returns an iterator over all the headers that have been inserted.

    Returns IterableIterator<[string, string]>

get

  • get(name: string): undefined | string
  • Gets the header with the given name, or returns undefined if it's not there.

    If there are multiple header values they will be joined together.

    Parameters

    • name: string

    Returns undefined | string

has

  • has(name: string): boolean
  • Determines whether there is a header with the given name in the map.

    Parameters

    • name: string

    Returns boolean

keys

  • keys(): IterableIterator<string>
  • Returns an iterator over all the header names in the map.

    Returns IterableIterator<string>

set

  • set(name: string, value: string): void
  • Sets the given header name to the given value.

    If there were any headers with the same name in the map before, they are overwritten.

    Parameters

    • name: string

      The name of the header to insert.

    • value: string

      The value of the header to insert.

    Returns void

toRecord

  • toRecord(): Record<string, string[]>
  • Converts the header map into a record.

    Returns Record<string, string[]>

    The record.

values

  • values(): IterableIterator<string>
  • Returns an iterator over all the header values in the map.

    Returns IterableIterator<string>

Generated using TypeDoc