Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions include/hpack/hpack.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,19 @@ V decode_headers_block(decoder& dec, std::span<const byte_t> 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<const byte_t> 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<const byte_t>(b, e));
}

} // namespace hpack
2 changes: 2 additions & 0 deletions tests/test_hpack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1119,6 +1119,8 @@ TEST(encode_with_cache) {
}

int main() {
static_assert(hpack::noexport::can_insert_many<std::vector<hpack::byte_t>>);
static_assert(hpack::noexport::can_insert_many<std::vector<char>>);
test_stream_decoder_big_str();
test_stream_decoder();
test_tg_answer_parts();
Expand Down