| 1128 | } |
| 1129 | |
| 1130 | int |
| 1131 | QPACK::_on_encoder_stream_read_ready(IOBufferReader &reader) |
| 1132 | { |
| 1133 | while (reader.is_read_avail_more_than(0)) { |
| 1134 | uint8_t buf; |
| 1135 | reader.memcpy(&buf, 1); |
| 1136 | if (buf & 0x80) { // Insert With Name Reference |
| 1137 | bool is_static; |
| 1138 | uint16_t index; |
| 1139 | const char *name; |
| 1140 | size_t name_len; |
| 1141 | const char *dummy; |
| 1142 | size_t dummy_len; |
| 1143 | char *value; |
| 1144 | size_t value_len; |
| 1145 | if (this->_read_insert_with_name_ref(reader, is_static, index, this->_arena, &value, value_len) < 0) { |
| 1146 | this->_abort_decode(); |
| 1147 | return EVENT_DONE; |
| 1148 | } |
| 1149 | QPACKDebug("Received Insert With Name Ref: is_static=%d, index=%d, value=%.*s", is_static, index, static_cast<int>(value_len), |
| 1150 | value); |
| 1151 | StaticTable::lookup(index, &name, &name_len, &dummy, &dummy_len); |
| 1152 | this->_dynamic_table.insert_entry(name, name_len, value, value_len); |
| 1153 | this->_arena.str_free(value); |
| 1154 | } else if (buf & 0x40) { // Insert Without Name Reference |
| 1155 | char *name; |
| 1156 | size_t name_len; |
| 1157 | char *value; |
| 1158 | size_t value_len; |
| 1159 | if (this->_read_insert_without_name_ref(reader, this->_arena, &name, name_len, &value, value_len) < 0) { |
| 1160 | this->_abort_decode(); |
| 1161 | return EVENT_DONE; |
| 1162 | } |
| 1163 | QPACKDebug("Received Insert Without Name Ref: name=%.*s, value=%.*s", static_cast<int>(name_len), name, |
| 1164 | static_cast<int>(value_len), value); |
| 1165 | this->_dynamic_table.insert_entry(name, name_len, value, value_len); |
| 1166 | this->_arena.str_free(name); |
| 1167 | } else if (buf & 0x20) { // Dynamic Table Size Update |
| 1168 | uint16_t max_size; |
| 1169 | if (this->_read_dynamic_table_size_update(reader, max_size) < 0) { |
| 1170 | this->_abort_decode(); |
| 1171 | return EVENT_DONE; |
| 1172 | } |
| 1173 | QPACKDebug("Received Dynamic Table Size Update: max_size=%d", max_size); |
| 1174 | this->_dynamic_table.update_maximum_size(max_size); |
| 1175 | } else { // Duplicates |
| 1176 | uint16_t index; |
| 1177 | if (this->_read_duplicate(reader, index) < 0) { |
| 1178 | this->_abort_decode(); |
| 1179 | return EVENT_DONE; |
| 1180 | } |
| 1181 | QPACKDebug("Received Duplicate: index=%d", index); |
| 1182 | this->_dynamic_table.duplicate_entry(index); |
| 1183 | } |
| 1184 | |
| 1185 | this->_resume_decode(); |
| 1186 | } |
| 1187 |
no test coverage detected