Support h2c upgrade
h2c upgrade is a mechanism for supporting http/2 on connections that
might not support alpn [1]. This is done by the client specifying
Connection: upgrade
Upgrade: h2c
This looks very similar to a websocket upgrade, which h2c replacing
websocket. Because of this, the existing upgrade code needs some
upgrades to avoid parsing twice.
Tested:
```
curl -u root:0penBmc --http2 -k http://192.168.7.2:443/redfish/v1/SessionService/Sessions
```
Succeeds and verbose logging shows that http upgrade succeeded
websocket_test.py in the scripts directory connects and reports events
[1] https://datatracker.ietf.org/doc/html/rfc7540#section-11.8
Change-Id: I8f76e355f99f21337d310ef2f345e6aaa253b48b
Signed-off-by: Ed Tanous <etanous@nvidia.com>
diff --git a/http/nghttp2_adapters.hpp b/http/nghttp2_adapters.hpp
index 8333b25..ff5e708 100644
--- a/http/nghttp2_adapters.hpp
+++ b/http/nghttp2_adapters.hpp
@@ -9,7 +9,9 @@
#include "logging.hpp"
+#include <bit>
#include <span>
+#include <string_view>
/* This file contains RAII compatible adapters for nghttp2 structures. They
* attempt to be as close to a direct call as possible, while keeping the RAII
@@ -139,6 +141,14 @@
return nghttp2_submit_settings(ptr, NGHTTP2_FLAG_NONE, iv.data(),
iv.size());
}
+
+ int sessionUpgrade2(std::string_view settingsPayload, bool headRequest)
+ {
+ return nghttp2_session_upgrade2(
+ ptr, std::bit_cast<uint8_t*>(settingsPayload.data()),
+ settingsPayload.size(), headRequest ? 1 : 0, nullptr);
+ }
+
void setUserData(void* object)
{
nghttp2_session_set_user_data(ptr, object);