Skip to content

Commit b9f4c06

Browse files
author
kelbon
committed
ignore headers block
1 parent a6cd369 commit b9f4c06

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

include/hpack/hpack.hpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,19 @@ V decode_headers_block(decoder& dec, std::span<const byte_t> bytes, V visitor) {
3535
return visitor;
3636
}
3737

38+
// should be used when endpoint wants to skip headers without breaking decoder state
39+
inline void ignore_headers_block(decoder& dec, std::span<const byte_t> bytes) {
40+
// entry size calculated as name.size() + value.size() + 32,
41+
// so minimal possible header to fit into dynamic table - "" "" with size 32
42+
if (dec.dyntab.max_size() < 32)
43+
return;
44+
// maintains dynamic table in decoder
45+
decode_headers_block(dec, bytes, [](std::string_view, std::string_view) {});
46+
}
47+
48+
// should be used when endpoint wants to skip headers without breaking decoder state
49+
inline void ignore_headers_block(decoder& dec, In b, In e) {
50+
ignore_headers_block(dec, std::span<const byte_t>(b, e));
51+
}
52+
3853
} // namespace hpack

tests/test_hpack.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,6 +1119,8 @@ TEST(encode_with_cache) {
11191119
}
11201120

11211121
int main() {
1122+
static_assert(hpack::noexport::can_insert_many<std::vector<hpack::byte_t>>);
1123+
static_assert(hpack::noexport::can_insert_many<std::vector<char>>);
11221124
test_stream_decoder_big_str();
11231125
test_stream_decoder();
11241126
test_tg_answer_parts();

0 commit comments

Comments
 (0)