diff --git a/include/hpack/hpack.hpp b/include/hpack/hpack.hpp index 84d9073..a6a0778 100644 --- a/include/hpack/hpack.hpp +++ b/include/hpack/hpack.hpp @@ -35,4 +35,19 @@ V decode_headers_block(decoder& dec, std::span bytes, V visitor) { return visitor; } +// should be used when endpoint wants to skip headers without breaking decoder state +inline void ignore_headers_block(decoder& dec, std::span bytes) { + // entry size calculated as name.size() + value.size() + 32, + // so minimal possible header to fit into dynamic table - "" "" with size 32 + if (dec.dyntab.max_size() < 32) + return; + // maintains dynamic table in decoder + decode_headers_block(dec, bytes, [](std::string_view, std::string_view) {}); +} + +// should be used when endpoint wants to skip headers without breaking decoder state +inline void ignore_headers_block(decoder& dec, In b, In e) { + ignore_headers_block(dec, std::span(b, e)); +} + } // namespace hpack diff --git a/tests/test_hpack.cpp b/tests/test_hpack.cpp index 3ad42da..cb8da0b 100644 --- a/tests/test_hpack.cpp +++ b/tests/test_hpack.cpp @@ -1119,6 +1119,8 @@ TEST(encode_with_cache) { } int main() { + static_assert(hpack::noexport::can_insert_many>); + static_assert(hpack::noexport::can_insert_many>); test_stream_decoder_big_str(); test_stream_decoder(); test_tg_answer_parts();