This library is based on @tatsuhiro-t nghttp2 library (https://github.com/nghttp2/nghttp2). It offers a quick way to instantiate a client or server and define their virtual methods to process the requests and answers properly.
You could check an example of use at h2agent project, where the server side capability is used to mock an HTTP/2 service within a testing ecosystem.
The project uses a single multi-stage Dockerfile with all dependencies built from source. No external builder images are required -- the build is fully self-contained from ubuntu:24.04.
| Target | Produces | Description |
|---|---|---|
deps |
http2comm_builder |
Toolchain + all libraries installed. |
build |
http2comm |
deps + http2comm compiled and installed. |
$ ./build.sh # builds everything (deps + library)
$ ./build.sh --builder # builds only deps stageOr directly with Docker:
$ docker build --target build -t http2comm . # full build
$ docker build --target deps -t http2comm_builder . # deps onlyImages are available at github container registry for every repository tag, and also for master as latest:
$ docker pull ghcr.io/testillano/http2comm:<tag>All dependency versions are declared as ARG at the top of the Dockerfile. Override any version at build time:
$ docker build --build-arg ert_metrics_ver=v1.3.0 -t http2comm .
$ ert_metrics_ver=v1.3.0 ./build.shThis is a cmake-based library. Once dependencies are installed (see Dockerfile ARGs and RUN steps for the full list):
$ cmake . && make -j$(nproc)You could specify type of build:
$ cmake -DCMAKE_BUILD_TYPE=Debug .
$ cmake -DCMAKE_BUILD_TYPE=Release .All dependencies and their versions are documented in the Dockerfile itself (the ARG declarations at the top and the RUN steps that install them).
$ make$ make clean$ make doc$ sudo make install$ cat install_manifest.txt | sudo xargs rmTo embed the library directly into an existing CMake project, place the entire source tree in a subdirectory and call add_subdirectory() in your CMakeLists.txt file:
add_subdirectory(ert_http2comm)
...
add_library(foo ...)
...
target_link_libraries(foo PRIVATE ert_http2comm::ert_http2comm)Since CMake v3.11, FetchContent can be used to automatically download the repository as a dependency at configure time.
Example:
include(FetchContent)
FetchContent_Declare(ert_http2comm
GIT_REPOSITORY https://github.com/testillano/http2comm.git
GIT_TAG vx.y.z)
FetchContent_GetProperties(ert_http2comm)
if(NOT ert_http2comm_POPULATED)
FetchContent_Populate(ert_http2comm)
add_subdirectory(${ert_http2comm_SOURCE_DIR} ${ert_http2comm_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()
target_link_libraries(foo PRIVATE ert_http2comm::ert_http2comm)Downstream applications (h2agent) no longer inherit from this image directly. They install http2comm from source in their own multi-stage Dockerfile with pinned versions.
Please, execute astyle formatting before any pull request:
$ sources=$(find . -name "*.hpp" -o -name "*.cpp")
$ docker run -i --rm -v $PWD:/data frankwolf/astyle ${sources}