Simplify HTTP/2 buffering
Using the mem_send methods of nghttp2 can reduce the amount of buffering
we need to do. This is recommended by the nghttp2 docs.
Tested: Enabled experimental-http. Curl succeeds on /redfish/v1, and
shows:
* using HTTP/2
* [HTTP/2] [1] OPENED stream for https://localhost:18080/redfish/v1
Change-Id: I287d8c956f064d244116fac853055a17fca915a2
Signed-off-by: Ed Tanous <ed@tanous.net>
diff --git a/http/nghttp2_adapters.hpp b/http/nghttp2_adapters.hpp
index 9f4dc91..05ea68d 100644
--- a/http/nghttp2_adapters.hpp
+++ b/http/nghttp2_adapters.hpp
@@ -135,9 +135,11 @@
return nghttp2_session_mem_recv(ptr, buffer.data(), buffer.size());
}
- ssize_t send()
+ std::span<const uint8_t> memSend()
{
- return nghttp2_session_send(ptr);
+ const uint8_t* bytes = nullptr;
+ ssize_t size = nghttp2_session_mem_send(ptr, &bytes);
+ return {bytes, static_cast<size_t>(size)};
}
int submitResponse(int32_t streamId, std::span<const nghttp2_nv> headers,