Module: HTTP2::BufferUtils

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

Instance Method Summary collapse

Instance Method Details

#read_str(str, n) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/http/2/extensions.rb', line 5

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



14
15
16
# File 'lib/http/2/extensions.rb', line 14

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

#shift_byte(str) ⇒ Object



18
19
20
# File 'lib/http/2/extensions.rb', line 18

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