class HPack::DynamicTable

Overview

The DynamicTable is a table of header names and values. It is implemented as a subclass of a Deque in order to get access to all of the iteration and interrogation methods without having to write methods which explicitly wrap them. Fewer lines to maintain is a win. As a caveat, though, do not interact with the storage or deletion of data via any methods other than #add, #clear, #find_index, #find_name_index, and #rebuild_index, as the native Deque methods will not keep an accurate tally of the bytesize of the structure nor of the hash indexes used for O(1) lookup.

#eviction_listener, #drop_newest, #restore_evicted, and #restore_insert_count (each marked :nodoc:) are public only because Encoder#with_writer's transactional rollback is a different class and needs to call them; they exist solely to support that rollback and are not part of this class's supported API otherwise.

Defined in:

dynamic_table.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(maximum : Int32 = 4096) #

[View source]

Instance Method Detail

def add(name, value) #

[View source]
def bytesize : Int32 #

[View source]
def clear #
Description copied from class Deque({String, String})

Removes all elements from self.


[View source]
def find_index(name : String, value : String) : Int32 | Nil #

Returns the 1-based relative index (1 = newest) of the entry whose name and value match exactly, or nil if absent.


[View source]
def find_name_index(name : String) : Int32 | Nil #

Returns the 1-based relative index (1 = newest) of the most recent entry whose name matches, or nil if absent.


[View source]
def insert_count : UInt64 #

Current insertion sequence counter. Exposed only for transactional rollback: some insertions made during a failed transaction may have already been evicted (and are therefore invisible to drop_newest), so the counter cannot always be recovered purely by counting drop_newest calls; rollback instead restores it directly from a value captured at transaction start.


[View source]
def maximum : Int32 #

[View source]
def maximum=(maximum : Int32) #

[View source]
def rebuild_index : Nil #

Rebuilds both hash indexes from current contents. Used only on transactional rollback (rare path).


[View source]
def resize(maximum : Int32) #

Changes this table's local capacity and evicts entries as needed.

Encoder users applying a negotiated capacity change should call Encoder#resize_table instead so the peer receives the required HPACK dynamic-table size update.


[View source]