Module: Biryani::HPACK::String
- Defined in:
- lib/biryani/hpack/string.rb
Class Method Summary collapse
- .decode(io, cursor) ⇒ String, Integer
-
.encode(s) ⇒ String
0 1 2 3 4 5 6 7
---—---—---—---—+ | H | String Length (7+) |---—————————+ | String Data (Length octets) |-------------------------------datatracker.ietf.org/doc/html/rfc7541#section-5.2.
Class Method Details
.decode(io, cursor) ⇒ String, Integer
31 32 33 34 35 36 37 |
# File 'lib/biryani/hpack/string.rb', line 31 def self.decode(io, cursor) h = (io.get_value(:U8, cursor) & 0b10000000).positive? len, c = Integer.decode(io, 7, cursor) return [Huffman.decode(io, c, len), c + len] if h [io.get_string(c, len), c + len] end |
.encode(s) ⇒ String
0 1 2 3 4 5 6 7 ---—---—---—---—+ | H | String Length (7+) | ---—————————+ | String Data (Length octets) | ------------------------------- datatracker.ietf.org/doc/html/rfc7541#section-5.2
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/biryani/hpack/string.rb', line 15 def self.encode(s) res = Huffman.encode(s) mask = 0b10000000 if res.bytesize > s.bytesize res = s mask = 0b00000000 end Integer.encode(res.bytesize, 7, mask) + res end |