lib/protocol/hpack/context.rb in protocol-hpack-1.3.0 vs lib/protocol/hpack/context.rb in protocol-hpack-1.4.0
- old
+ new
@@ -149,11 +149,13 @@
# @return [Array] +[key, value]+
def dereference(index)
# NOTE: index is zero-based in this module.
value = STATIC_TABLE[index] || @table[index - STATIC_TABLE.size]
- raise CompressionError, "Index #{index} too large" unless value
+ if value.nil?
+ raise CompressionError, "Index #{index} too large!"
+ end
return value
end
# Header Block Processing
@@ -283,10 +285,17 @@
# When the size is reduced, some headers might be evicted.
def table_size= size
@table_size = size
size_check(nil)
end
-
+
+ def change_table_size(size)
+ self.table_size = size
+
+ # The command to resize the table:
+ return {type: :change_table_size, value: size}
+ end
+
# Returns current table size in octets
# @return [Integer]
def current_table_size
@table.inject(0) {|r, (k, v)| r + k.bytesize + v.bytesize + 32}
end