summaryrefslogtreecommitdiff
path: root/http/nghttp2_adapters.hpp
AgeCommit message (Collapse)AuthorFilesLines
2024-03-28Rename http2 unpackerEd Tanous1-8/+15
These classes accidentally overlapped in naming with the nghttp2 classes. This is because this class, unlike most nghttp2 classes doesn't end in _ptr for a type. This changes the class name to add a _ex to differentiate the two classes, and avoid a warning in clang. Tested: Unit tests pass. Code only used in unit test. Change-Id: I91a6982264df69bc65166ab38feddc21f72cd223 Signed-off-by: Ed Tanous <ed@tanous.net>
2024-03-21Allow reading http2 bodiesEd Tanous1-0/+7
This allows http2 connections to now host authenticated endpoints. Note, this work exposed that the http2 path was not calling preparePayload() and responses were therefore missing the Content-Length header. preparePayload is now called, and Content-Length is added to the unit tests. This commit also allows a full Redfish Service Validator test to pass entirely using HTTP2. Tested: Unit tests pass. Curl /redfish/v1/Managers/bmc/LogServices/Journal/Entries (which returns a payload larger than 16kB) succeeds and returns the data. Manually logging in with both basic and session authentication succeeds over http2. A modified Redfish-Service-Validator, changed to use httpx as its backend, (thus using http2) succeeds. Change-Id: I956f3ff8f442e9826312c6147d7599ab136a8e7c Signed-off-by: Ed Tanous <ed@tanous.net>
2024-02-16Write unit tests for http2 connectionEd Tanous1-0/+39
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>
2024-02-16Simplify HTTP/2 bufferingEd Tanous1-2/+4
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>
2023-07-20Replace logging with std::formatEd Tanous1-1/+1
std::format is a much more modern logging solution, and gives us a lot more flexibility, and better compile times when doing logging. Unfortunately, given its level of compile time checks, it needs to be a method, instead of the stream style logging we had before. This requires a pretty substantial change. Fortunately, this change can be largely automated, via the script included in this commit under scripts/replace_logs.py. This is to aid people in moving their patchsets over to the new form in the short period where old patches will be based on the old logging. The intention is that this script eventually goes away. The old style logging (stream based) looked like. BMCWEB_LOG_DEBUG << "Foo " << foo; The new equivalent of the above would be: BMCWEB_LOG_DEBUG("Foo {}", foo); In the course of doing this, this also cleans up several ignored linter errors, including macro usage, and array to pointer deconstruction. Note, This patchset does remove the timestamp from the log message. In practice, this was duplicated between journald and bmcweb, and there's no need for both to exist. One design decision of note is the addition of logPtr. Because the compiler can't disambiguate between const char* and const MyThing*, it's necessary to add an explicit cast to void*. This is identical to how fmt handled it. Tested: compiled with logging meson_option enabled, and launched bmcweb Saw the usual logging, similar to what was present before: ``` [Error include/webassets.hpp:60] Unable to find or open /usr/share/www/ static file hosting disabled [Debug include/persistent_data.hpp:133] Restored Session Timeout: 1800 [Debug redfish-core/include/event_service_manager.hpp:671] Old eventService config not exist [Info src/webserver_main.cpp:59] Starting webserver on port 18080 [Error redfish-core/include/event_service_manager.hpp:1301] inotify_add_watch failed for redfish log file. [Info src/webserver_main.cpp:137] Start Hostname Monitor Service... ``` Signed-off-by: Ed Tanous <ed@tanous.net> Change-Id: I86a46aa2454be7fe80df608cb7e5573ca4029ec8
2023-06-28HTTP/2 supportEd Tanous1-0/+152
HTTP/2 gives a number of optimizations, while keeping support for the protocol. HTTP/2 support was recently added to the Redfish specification. The largest performance increase in bmc usage is likely header compression. Almost all requests reuse the same header values, so the hpack based compression scheme in HTTP/2 allows OpenBMC to be more efficient as a transport, and has the potential to significantly reduce the number of bytes we're sending on the wire. This commit adds HTTP2 support to bmcweb through nghttp2 library. When static linked into bmcweb, this support adds 53.4KB to the bmcweb binary size. nghttp2 is available in meta-oe already. Given the experimental nature of this option, it is added under the meson option "experimental-http2" and disabled by default. The hope is to enable it at some point in the future. To accomplish the above, there a new class, HTTP2Connection is created. This is intended to isolate HTTP/2 connections code from HttpConnection such that it is far less likely to cause bugs, although it does duplicate about 20 lines of code (async_read_some, async_write_some, buffers, etc). This seems worth it for the moment. In a similar way to Websockets, when an HTTP/2 connection is detected through ALPN, the HTTP2Connection class will be instantiated, and the socket object passed to it, thus allowing the Connection class to be destroyed, and the HTTP2Connection to take over for the user. Tested: Redfish service validator passes with option enabled With option disabled GET /redfish/v1 in curl shows ALPN non negotiation, and fallback to http1.1 With the option enable GET /redfish/v1 in curl shows ALPN negotiates to HTTP2 Change-Id: I7839e457e0ba918b0695e04babddd0925ed3383c Signed-off-by: Ed Tanous <edtanous@google.com>