| 268 | } |
| 269 | |
| 270 | int |
| 271 | QPACK::decode(uint64_t stream_id, const uint8_t *header_block, size_t header_block_len, HTTPHdr &hdr, Continuation *cont, |
| 272 | EThread *thread) |
| 273 | { |
| 274 | if (!cont || !header_block) { |
| 275 | return -1; |
| 276 | } |
| 277 | |
| 278 | if (this->_invalid) { |
| 279 | thread->schedule_imm(cont, QPACK_EVENT_DECODE_FAILED, nullptr); |
| 280 | return -1; |
| 281 | } |
| 282 | |
| 283 | uint64_t tmp = 0; |
| 284 | int64_t ret = xpack_decode_integer(tmp, header_block, header_block + header_block_len, 8); |
| 285 | if (ret < 0 && tmp > 0xFFFF) { |
| 286 | return -1; |
| 287 | } |
| 288 | uint16_t largest_reference = tmp; |
| 289 | |
| 290 | if (largest_reference != 0 && (this->_dynamic_table.is_empty() || this->_dynamic_table.largest_index() < largest_reference)) { |
| 291 | // Blocked |
| 292 | if (this->_add_to_blocked_list( |
| 293 | new DecodeRequest(largest_reference, thread, cont, stream_id, header_block, header_block_len, hdr))) { |
| 294 | return 1; |
| 295 | } else { |
| 296 | // Number of blocked streams exceed the limit |
| 297 | return -2; |
| 298 | } |
| 299 | } |
| 300 | |
| 301 | this->_decode(thread, cont, stream_id, header_block, header_block_len, hdr); |
| 302 | |
| 303 | return 0; |
| 304 | } |
| 305 | |
| 306 | void |
| 307 | QPACK::set_encoder_stream(QUICStreamId id) |