Class HeadersWearable Only

Headers for the Fetch API in RemoteServiceModule. Allows you to perform actions on HTTP request and response headers, like retrieving, setting, adding to, and removing headers.

You can retrieve a Headers object via the Request.headers and Response.headers properties, and create a new Headers object using the Headers() constructor.

let myHeaders = new Headers();

myHeaders.append("Content-Type", "text/xml");
myHeaders.get("Content-Type"); // should return 'text/xml'

Hierarchy (View Summary, Expand)

Constructors

Methods

  • Append a new value onto an existing header inside a Headers object, or adds the header if it does not already exist.

    The difference between set() and append() is that if the specified header already exists and accepts multiple values, set() will overwrite the existing value with the new one, whereas append() will append the new value onto the end of the set of values.

    myHeaders.append("Accept-Encoding", "deflate");
    myHeaders.append("Accept-Encoding", "gzip");
    myHeaders.get("Accept-Encoding"); // Returns 'deflate, gzip'

    Parameters

    • name: string
    • value: string

    Returns void

  • Deletes a header from the Headers object.

    myHeaders.append("Content-Type", "image/jpeg");
    myHeaders.get("Content-Type"); // Returns 'image/jpeg'
    myHeaders.delete("Content-Type");
    myHeaders.get("Content-Type"); // Returns null, as it has been deleted

    Parameters

    • name: string

    Returns void

  • Returns an iterator allowing to go through all key/value pairs contained in this object. Both the key and value of each pair are String objects.

    // Print the key/value pairs
    for (const pair of myHeaders.entries()) {
    print(`${pair[0]}: ${pair[1]}`);
    }

    Returns string[][]

  • Returns a comma-separated string of all the values of a header within a Headers object with a given name. If the requested header doesn't exist in the Headers object, returns null.

    myHeaders.append("Accept-Encoding", "deflate");
    myHeaders.append("Accept-Encoding", "gzip");
    myHeaders.get("Accept-Encoding"); // Returns "deflate, gzip"

    Parameters

    • name: string

    Returns string

  • Returns a boolean stating whether the Headers object contains the given header.

    Parameters

    • name: string

    Returns boolean

  • Returns true if the object matches or derives from the passed in type.

    Parameters

    • type: string

    Returns boolean

  • Returns true if this object is the same as other. Useful for checking if two references point to the same thing.

    Parameters

    Returns boolean

  • Returns an iterator allowing you to go through all keys contained in the Headers. The keys are String objects.

    // Print the keys
    for (const key of myHeaders.keys()) {
    print(key);
    }

    Returns string[]

  • Sets a new value for an existing header inside a Headers object, or adds the header if it does not already exist.

    The difference between set() and Headers.append is that if the specified header already exists and accepts multiple values, set() overwrites the existing value with the new one, whereas Headers.append appends the new value to the end of the set of values.

    myHeaders.set("Accept-Encoding", "deflate");
    myHeaders.set("Accept-Encoding", "gzip");
    myHeaders.get("Accept-Encoding"); // Returns 'gzip'

    Parameters

    • name: string
    • value: string

    Returns void

  • Returns an iterator allowing you to go through all values contained in the Headers. The values are String objects.

    // Print the values
    for (const value of myHeaders.values()) {
    print(value);
    }

    Returns string[]

MMNEPVFCICPMFPCPTTAAATR