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 <ed@tanous.net>
diff --git a/http/nghttp2_adapters.hpp b/http/nghttp2_adapters.hpp
index 05ea68d..aeb18d6 100644
--- a/http/nghttp2_adapters.hpp
+++ b/http/nghttp2_adapters.hpp
@@ -152,3 +152,42 @@
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);
+ }
+ }
+};