HTTP header class.

Hierarchy

  • Headers

Constructors

  • Parameters

    • init: string[] = []

    Returns Headers

Properties

_headers?: HeaderBuffer
_init: string[]

Methods

  • Returns HeaderBuffer

  • Append header value.

    Parameters

    • name: string
    • value: string

    Returns Headers

  • Clone headers.

    Returns Headers

  • Remove hop-by-hop headers that should not be retransmitted.

    Returns Headers

  • Get header value.

    Parameters

    • name: string

    Returns null | string

  • Get all headers values individually.

    Parameters

    • name: string

    Returns string[]

  • Get web links from Link header according to RFC5988.

    Returns Record<string, Record<string, string>>

    Link

    http://tools.ietf.org/html/rfc5988

    Example

    // Extract information about next page
    const {link, title} = headers.getLinks().next;
  • Remove header.

    Parameters

    • name: string

    Returns Headers

  • Set header value.

    Parameters

    • name: string
    • value: string

    Returns Headers

  • Set web links to Link header according to RFC5988.

    Parameters

    • links: Record<string, string>

    Returns Headers

    Link

    http://tools.ietf.org/html/rfc5988

    Example

    // Link to next and previous page
    headers.setLinks({next: 'http://example.com/foo', prev: 'http://example.com/bar'});
  • Convert headers into a plain array of name/value pairs.

    Returns string[]

  • Convert headers into a plain object.

    Returns Record<string, string>

  • Convert headers to string.

    Returns string

Generated using TypeDoc