class ObjectFramework::HTTP2::HPACK::Cursor
Public Class Methods
Source
# File lib/object_framework/http2/hpack.rb, line 86 def initialize(bytes); @bytes, @offset = bytes.b, 0; end
Public Instance Methods
Source
# File lib/object_framework/http2/hpack.rb, line 87 def done?; @offset == @bytes.bytesize; end
Source
# File lib/object_framework/http2/hpack.rb, line 97 def integer(prefix) maximum = (1 << prefix) - 1 value = take(1).getbyte(0) & maximum return value if value < maximum 9.times do |index| byte = take(1).getbyte(0) value += (byte & 127) << (index * 7) raise CompressionError if value > 2**63 - 1 return value if byte < 128 end raise CompressionError end
Source
# File lib/object_framework/http2/hpack.rb, line 88 def peek; @bytes.getbyte(@offset) || raise(CompressionError); end
Source
# File lib/object_framework/http2/hpack.rb, line 110 def string(limit:) huffman = (peek & 128).positive? length = integer(7) value = take(length) value = Huffman.decode(value, limit:) if huffman raise CompressionError if value.bytesize > limit value end
Source
# File lib/object_framework/http2/hpack.rb, line 90 def take(count) raise CompressionError if count.negative? || @offset + count > @bytes.bytesize result = @bytes.byteslice(@offset, count) @offset += count result end