UNPKG

@fastly/as-fetch

Version:

![npm version](https://img.shields.io/npm/v/@fastly/as-fetch) ![npm downloads per month](https://img.shields.io/npm/dm/@fastly/as-fetch)

169 lines (95 loc) 2.85 kB
[@fastly/as-fetch](../README.md) / Headers # Class: Headers Headers for a [Fetch HTTP Request/Response](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#Headers). ## Table of contents ### Constructors - [constructor](headers.md#constructor) ### Methods - [\_headerNameToLowercase](headers.md#_headernametolowercase) - [append](headers.md#append) - [delete](headers.md#delete) - [get](headers.md#get) - [has](headers.md#has) - [keys](headers.md#keys) - [set](headers.md#set) - [values](headers.md#values) ## Constructors ### constructor • **new Headers**() ## Methods ### \_headerNameToLowercase`Private` **_headerNameToLowercase**(`name`): `string` #### Parameters | Name | Type | | :------ | :------ | | `name` | `string` | #### Returns `string` ___ ### append ▸ **append**(`name`, `value`): `void` Append a header value to a given name. #### Parameters | Name | Type | Description | | :------ | :------ | :------ | | `name` | `string` | The name of the HTTP header to set. | | `value` | `string` | The value of the HTTP header to set. | #### Returns `void` ___ ### delete ▸ **delete**(`name`): `void` Remove a header from from the `Header` instance. #### Parameters | Name | Type | Description | | :------ | :------ | :------ | | `name` | `string` | The name of the HTTP header you want to remove from the `Header` instance. | #### Returns `void` ___ ### get ▸ **get**(`name`): ``null`` \| `string` Get the value of a header by it's name. #### Parameters | Name | Type | Description | | :------ | :------ | :------ | | `name` | `string` | string of the name of the header value you would want. | #### Returns ``null`` \| `string` the value associated with the header name if it exists. ___ ### has ▸ **has**(`name`): `boolean` Checks for header name existance. #### Parameters | Name | Type | Description | | :------ | :------ | :------ | | `name` | `string` | The name of the HTTP header you want to know if exists on the headers instance. | #### Returns `boolean` a boolean of whether or not the header exists. ___ ### keys ▸ **keys**(): `string`[] Get all of the `Header` instance's names/keys. #### Returns `string`[] an `Array` of `string`s containing all of the names/keys on the `Header` instance. ___ ### set ▸ **set**(`name`, `value`): `void` Set or Override a header of a given name. #### Parameters | Name | Type | Description | | :------ | :------ | :------ | | `name` | `string` | The name of the HTTP header to set. | | `value` | `string` | The value of the HTTP header to set. | #### Returns `void` ___ ### values ▸ **values**(): `string`[][] Get all of the `Header` instance's values. #### Returns `string`[][] an `Array` of `Array` of `string`s containing all of the values for each name on a `Header` instance.