Module: HTTP2::PackingExtensions

Included in:
Framer, Header::Compressor, Header::Huffman
Defined in:
lib/http/2/extensions.rb

Overview

this mixin handles backwards-compatibility for the new packing options shipping with ruby 3.3 (see docs.ruby-lang.org/en/3.3/packed_data_rdoc.html)

Instance Method Summary collapse

Instance Method Details

#pack(array_to_pack, template, buffer:, offset: -1)) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/http/2/extensions.rb', line 29

def pack(array_to_pack, template, buffer:, offset: -1)
  packed_str = array_to_pack.pack(template)
  case offset
  when -1
    buffer << packed_str
  when 0
    buffer.prepend(packed_str)
  else
    buffer.insert(offset, packed_str)
  end
end