From 52dd6932dea23ed6f6ae24caec12c9a7f19c2284 Mon Sep 17 00:00:00 2001 From: Ed Tanous Date: Mon, 29 Jan 2024 08:34:59 -0800 Subject: Write unit tests for http2 connection This unit test currently only tests a simple connect and settings frame transfer, but should form the basis for more complex testing in the future. Tested: Unit tests pass Change-Id: Ieb803dbe490129ec5fe99fb3d4505a06202e282e Signed-off-by: Ed Tanous --- http/nghttp2_adapters.hpp | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'http') diff --git a/http/nghttp2_adapters.hpp b/http/nghttp2_adapters.hpp index 05ea68d388..aeb18d60ab 100644 --- a/http/nghttp2_adapters.hpp +++ b/http/nghttp2_adapters.hpp @@ -152,3 +152,42 @@ struct nghttp2_session private: nghttp2_session* ptr = nullptr; }; + +class nghttp2_hd_inflater +{ + nghttp2_hd_inflater* ptr = nullptr; + + public: + nghttp2_hd_inflater() + { + if (nghttp2_hd_inflate_new(&ptr) != 0) + { + BMCWEB_LOG_ERROR("nghttp2_hd_inflater_new failed"); + } + } + + ssize_t hd2(nghttp2_nv* nvOut, int* inflateFlags, const uint8_t* in, + size_t inlen, int inFinal) + { + return nghttp2_hd_inflate_hd2(ptr, nvOut, inflateFlags, in, inlen, + inFinal); + } + + int endHeaders() + { + return nghttp2_hd_inflate_end_headers(ptr); + } + + nghttp2_hd_inflater(const nghttp2_hd_inflater&) = delete; + nghttp2_hd_inflater& operator=(const nghttp2_hd_inflater&) = delete; + nghttp2_hd_inflater& operator=(nghttp2_hd_inflater&&) = delete; + nghttp2_hd_inflater(nghttp2_hd_inflater&& other) = delete; + + ~nghttp2_hd_inflater() + { + if (ptr != nullptr) + { + nghttp2_hd_inflate_del(ptr); + } + } +}; -- cgit v1.2.3