UNPKG

@arcjet/headers

Version:

Arcjet extension of the Headers class

36 lines (35 loc) 1.4 kB
/** * This Fetch API interface allows you to perform various actions on HTTP * request and response headers. These actions include retrieving, setting, * adding to, and removing. A Headers object has an associated header list, * which is initially empty and consists of zero or more name and value pairs. * * You can add to this using methods like `append()`. * * In all methods of this interface, header names are matched by * case-insensitive byte sequence. * * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers) */ export default class ArcjetHeaders extends Headers { constructor(init?: HeadersInit | Record<string, string | string[] | undefined>); /** * Append a key and value to the headers, while filtering any key named * `cookie`. * * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/append) * * @param key The key to append in the headers * @param value The value to append for the key in the headers */ append(key: string, value: string): void; /** * Set a key and value in the headers, but filtering any key named `cookie`. * * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/set) * * @param key The key to set in the headers * @param value The value to set for the key in the headers */ set(key: string, value: string): void; }