class

Awscr::Signer::HeaderCollection

Inherits Indexable < Enumerable < Iterable < Enumerable < Reference < Object

An array like structure that holds Header objects. Duplicated headers are merged into a single header. The data structure maintains proper ordering of the headers.

headers = HeaderCollection.new
headers.add(Header.new("k", "v"))
headers.to_a # => [Header.new("k", "v")]

Constants

BLACKLIST_HEADERS = ["cache-control", "content-length", "expect", "max-forwards", "pragma", "te", "if-match", "if-none-match", "if-modified-since", "if-unmodified-since", "if-range", "accept", "authorization", "proxy-authorization", "from", "referer", "user-agent"]

List of headers names not allowed in the collection.

Instance methods

[]=(key, value)

Set or add a header by key value

Source
[]?(key) : Header | Nil

Get a header by key, or nil of it does not exit

Source
add(k : String, v : String) : HeaderCollection

Adds a header to the collection. Merging duplicate header keys as per AWS requirements

Source
add(header : Header) : HeaderCollection

Adds a Header to the internal header list If the header already exists, it's value is updated

Source
delete(header : Header)

Deletes the header

Source
delete(key : String)

Deletes a header by a string

Source
each

Yields each header

Source
keys

Returns a list of the header keys ie: names

Source
size

Returns the number of elements in this container.

Source
to_s(io : IO)

Returns the collection of headers separated by newline with a trailing new line added

Source
unsafe_fetch(index : Int) : Header

Returns the element at the given index, without doing any bounds check.

Indexable makes sure to invoke this method with index in 0...size, so converting negative indices to positive ones is not needed here.

Clients never invoke this method directly. Instead, they access elements with #[](index) and #[]?(index).

This method should only be directly invoked if you are absolutely sure the index is in bounds, to avoid a bounds check for a small boost of performance.

Source