Module: HTTP2::BufferUtils

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

Instance Method Summary collapse

Instance Method Details

#append_str(str, data) ⇒ Object



6
7
8
# File 'lib/http/2/extensions.rb', line 6

def append_str(str, data)
  str.append_as_bytes(data)
end

#read_str(str, n) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/http/2/extensions.rb', line 25

def read_str(str, n)
  return "".b if n == 0

  chunk = str.byteslice(0..n - 1)
  remaining = str.byteslice(n..-1)
  remaining ? str.replace(remaining) : str.clear
  chunk
end

#read_uint32(str) ⇒ Object



34
35
36
# File 'lib/http/2/extensions.rb', line 34

def read_uint32(str)
  read_str(str, 4).unpack1("N")
end

#shift_byte(str) ⇒ Object



38
39
40
# File 'lib/http/2/extensions.rb', line 38

def shift_byte(str)
  read_str(str, 1).ord
end