Taxum / @taxum/core / http / HeaderMap
Class: HeaderMap
Defined in: http/headers.ts:15
Represents a case-insensitive map for HTTP headers.
Allows insertion, appending, removal, clearing, and extending of key-value pairs.
Implements
Constructors
Constructor
new HeaderMap(
entries?
):HeaderMap
Defined in: http/headers.ts:24
Creates a new HeaderMap.
You can optionally provide entries to initialize the map with existing key-value pairs.
Parameters
entries?
HeaderMap
| Iterable
<HeaderEntry
, any
, any
>
Returns
HeaderMap
Properties
map
protected
readonly
map:Map
<string
,HeaderValue
[]>
Defined in: http/headers.ts:16
Methods
[iterator]()
[iterator]():
IterableIterator
<HeaderEntry
>
Defined in: http/headers.ts:166
Returns
IterableIterator
<HeaderEntry
>
[TO_HTTP_RESPONSE_PARTS]()
[TO_HTTP_RESPONSE_PARTS](
res
):void
Defined in: http/headers.ts:259
Parameters
res
Returns
void
Implementation of
ToHttpResponseParts.[TO_HTTP_RESPONSE_PARTS]
append()
append(
key
,value
):void
Defined in: http/headers.ts:188
Appends a value to the list of values associated with the specified key.
If the key does not exist, it initializes a new list and adds the value to it.
Parameters
key
string
value
Returns
void
clear()
clear():
void
Defined in: http/headers.ts:213
Clears the entire map.
Returns
void
containsKey()
containsKey(
key
):boolean
Defined in: http/headers.ts:108
Checks if the given key exists in the map.
Parameters
key
string
Returns
boolean
entries()
entries():
IterableIterator
<HeaderEntry
>
Defined in: http/headers.ts:158
Returns an iterator of key-value pairs where keys and values are strings.
Each key may correspond to multiple values, and the iterator yields each key-value pair individually.
Returns
IterableIterator
<HeaderEntry
>
extend()
extend(
items
):void
Defined in: http/headers.ts:222
Extends the map by inserting key-value pairs from the given iterable.
Values in the iterable will overwrite existing values for the same key.
Parameters
items
Returns
void
get()
get(
key
):null
|HeaderValue
Defined in: http/headers.ts:115
Retrieves the first value associated with the specified key.
Parameters
key
string
Returns
null
| HeaderValue
getAll()
getAll(
key
): readonlyHeaderValue
[]
Defined in: http/headers.ts:128
Retrieves all values associated with the provided key.
Parameters
key
string
Returns
readonly HeaderValue
[]
insert()
insert(
key
,value
):void
Defined in: http/headers.ts:176
Inserts a key-value pair into the map.
If one or more values already exist for the key, they are replaced with the new value.
Parameters
key
string
value
Returns
void
isEmpty()
isEmpty():
boolean
Defined in: http/headers.ts:94
Determines whether the map contains no elements.
Returns
boolean
keys()
keys():
IterableIterator
<string
>
Defined in: http/headers.ts:135
Retrieves an iterator that allows iteration over all the keys in the map.
Returns
IterableIterator
<string
>
len()
len():
number
Defined in: http/headers.ts:101
Returns the number of elements in the map.
Returns
number
remove()
remove(
key
):null
|HeaderValue
Defined in: http/headers.ts:203
Removes the entry associated with the specified key from the map.
Parameters
key
string
Returns
null
| HeaderValue
toJSON()
toJSON():
Record
<string
,string
|string
[]>
Defined in: http/headers.ts:228
Returns
Record
<string
, string
| string
[]>
values()
values():
IterableIterator
<HeaderValue
>
Defined in: http/headers.ts:144
Returns an iterator that yields all values stored in the internal map.
The values are yielded sequentially from the inner collections.
Returns
IterableIterator
<HeaderValue
>
from()
static
from(entries
):HeaderMap
Defined in: http/headers.ts:56
Create a new HeaderMap from an Iterable
of key-value pairs.
This allows you to create the map from string values instead of HeaderValue
s.
Parameters
entries
Returns
HeaderMap
fromIncomingMessage()
static
fromIncomingMessage(message
):HeaderMap
Defined in: http/headers.ts:74
Creates a new HeaderMap from the provided IncomingMessage.
Converts the headers of the IncomingMessage into a map structure that can be used by the HeaderMap.
Parameters
message
Returns
HeaderMap