Class: Baykit::BayServer::Docker::Http::H2::HeaderBlock
- Inherits:
-
Object
- Object
- Baykit::BayServer::Docker::Http::H2::HeaderBlock
- Defined in:
- lib/baykit/bayserver/docker/http/h2/header_block.rb
Constant Summary collapse
- INDEX =
1- OVERLOAD_KNOWN_HEADER =
2- NEW_HEADER =
3- KNOWN_HEADER =
4- UNKNOWN_HEADER =
5- UPDATE_DYNAMIC_TABLE_SIZE =
6
Instance Attribute Summary collapse
-
#index ⇒ Object
Returns the value of attribute index.
-
#name ⇒ Object
Returns the value of attribute name.
-
#op ⇒ Object
Returns the value of attribute op.
-
#size ⇒ Object
Returns the value of attribute size.
-
#value ⇒ Object
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#index ⇒ Object
Returns the value of attribute index.
16 17 18 |
# File 'lib/baykit/bayserver/docker/http/h2/header_block.rb', line 16 def index @index end |
#name ⇒ Object
Returns the value of attribute name.
17 18 19 |
# File 'lib/baykit/bayserver/docker/http/h2/header_block.rb', line 17 def name @name end |
#op ⇒ Object
Returns the value of attribute op.
15 16 17 |
# File 'lib/baykit/bayserver/docker/http/h2/header_block.rb', line 15 def op @op end |
#size ⇒ Object
Returns the value of attribute size.
19 20 21 |
# File 'lib/baykit/bayserver/docker/http/h2/header_block.rb', line 19 def size @size end |
#value ⇒ Object
Returns the value of attribute value.
18 19 20 |
# File 'lib/baykit/bayserver/docker/http/h2/header_block.rb', line 18 def value @value end |
Class Method Details
.pack(blk, acc) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/baykit/bayserver/docker/http/h2/header_block.rb', line 21 def self.pack(blk, acc) case blk.op when INDEX acc.put_hpack_int(blk.index, 7, 1) when OVERLOAD_KNOWN_HEADER raise RuntimeError.new("IllegalState") when NEW_HEADER raise RuntimeError.new("Illegal State") when KNOWN_HEADER acc.put_hpack_int(blk.index, 4, 0) acc.put_hpack_string(blk.value, false) when UNKNOWN_HEADER acc.put_byte(0) acc.put_hpack_string(blk.name, false) acc.put_hpack_string(blk.value, false) when UPDATE_DYNAMIC_TABLE_SIZE raise RuntimeError.new("Illegal state") end end |
.unpack(acc) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/baykit/bayserver/docker/http/h2/header_block.rb', line 47 def self.unpack(acc) blk = HeaderBlock.new index = acc.get_byte is_index_header_field = (index & 0x80) != 0 if is_index_header_field # index header field # 0 1 2 3 4 5 6 7 # +---+---+---+---+---+---+---+---+ # | 1 | Index (7+) | # +---+---------------------------+ blk.op = INDEX blk.index = index & 0x7F else # literal header field update_index = (index & 0x40) != 0 if update_index index = index & 0x3F overload_index = (index != 0) if overload_index if index == 0x3F index = index + acc.get_hpack_int_rest end blk.op = OVERLOAD_KNOWN_HEADER blk.index = index # 0 1 2 3 4 5 6 7 # +---+---+---+---+---+---+---+---+ # | 0 | 1 | Index (6+) | # +---+---+-----------------------+ # | H | Value Length (7+) | # +---+---------------------------+ # | Value String (Length octets) | # +-------------------------------+ blk.value = acc.get_hpack_string else # new header name # 0 1 2 3 4 5 6 7 # +---+---+---+---+---+---+---+---+ # | 0 | 1 | 0 | # +---+---+-----------------------+ # | H | Name Length (7+) | # +---+---------------------------+ # | Name String (Length octets) | # +---+---------------------------+ # | H | Value Length (7+) | # +---+---------------------------+ # | Value String (Length octets) | # +-------------------------------+ blk.op = NEW_HEADER blk.name = acc.get_hpack_string blk.value = acc.get_hpack_string end else update_dynamic_table_size = (index & 0x20) != 0 if update_dynamic_table_size # 0 1 2 3 4 5 6 7 # +---+---+---+---+---+---+---+---+ # | 0 | 0 | 1 | Max size (5+) | # +---+---------------------------+ size = index & 0x1F if size == 0x1F size = size + acc.get_hpack_int_rest end blk.op = UPDATE_DYNAMIC_TABLE_SIZE blk.size = size else # not update index index = (index & 0xF) if index != 0 # 0 1 2 3 4 5 6 7 # +---+---+---+---+---+---+---+---+ # | 0 | 0 | 0 | 0 | Index (4+) | # +---+---+-----------------------+ # | H | Value Length (7+) | # +---+---------------------------+ # | Value String (Length octets) | # +-------------------------------+ # # OR # # 0 1 2 3 4 5 6 7 # +---+---+---+---+---+---+---+---+ # | 0 | 0 | 0 | 1 | Index (4+) | # +---+---+-----------------------+ # | H | Value Length (7+) | # +---+---------------------------+ # | Value String (Length octets) | # +-------------------------------+ if index == 0xF index = index + acc.get_hpack_int_rest end blk.op = KNOWN_HEADER blk.index = index blk.value = acc.get_hpack_string else # literal header field # 0 1 2 3 4 5 6 7 # +---+---+---+---+---+---+---+---+ # | 0 | 0 | 0 | 0 | 0 | # +---+---+-----------------------+ # | H | Name Length (7+) | # +---+---------------------------+ # | Name String (Length octets) | # +---+---------------------------+ # | H | Value Length (7+) | # +---+---------------------------+ # | Value String (Length octets) | # +-------------------------------+ # # OR # # 0 1 2 3 4 5 6 7 # +---+---+---+---+---+---+---+---+ # | 0 | 0 | 0 | 1 | 0 | # +---+---+-----------------------+ # | H | Name Length (7+) | # +---+---------------------------+ # | Name String (Length octets) | # +---+---------------------------+ # | H | Value Length (7+) | # +---+---------------------------+ # | Value String (Length octets) | # +-------------------------------+ # blk.op = UNKNOWN_HEADER blk.name = acc.get_hpack_string blk.value = acc.get_hpack_string end end end end blk end |
Instance Method Details
#to_s ⇒ Object
181 182 183 |
# File 'lib/baykit/bayserver/docker/http/h2/header_block.rb', line 181 def to_s "#{op} index=#{index} name=#{name} value=#{value}" end |