From f67c52909b83bf47854a562eacf05c46ab2b588c Mon Sep 17 00:00:00 2001 From: f-fl0 <66578286+f-fl0@users.noreply.github.com> Date: Mon, 9 Sep 2024 15:14:42 +0900 Subject: [PATCH] Backport cpp-httplib (#1015) --- v3.17/backports/cpp-httplib/APKBUILD | 45 +++++++++++++++ .../disable-ipv6-related-tests.patch | 15 +++++ .../cpp-httplib/fix-test-makefile.patch | 25 +++++++++ v3.20/backports/cpp-httplib/APKBUILD | 47 ++++++++++++++++ .../disable-ipv6-related-tests.patch | 15 +++++ .../disable-ssl-certificates-tests.patch | 56 +++++++++++++++++++ .../cpp-httplib/fix-test-makefile.patch | 25 +++++++++ 7 files changed, 228 insertions(+) create mode 100644 v3.17/backports/cpp-httplib/APKBUILD create mode 100644 v3.17/backports/cpp-httplib/disable-ipv6-related-tests.patch create mode 100644 v3.17/backports/cpp-httplib/fix-test-makefile.patch create mode 100644 v3.20/backports/cpp-httplib/APKBUILD create mode 100644 v3.20/backports/cpp-httplib/disable-ipv6-related-tests.patch create mode 100644 v3.20/backports/cpp-httplib/disable-ssl-certificates-tests.patch create mode 100644 v3.20/backports/cpp-httplib/fix-test-makefile.patch diff --git a/v3.17/backports/cpp-httplib/APKBUILD b/v3.17/backports/cpp-httplib/APKBUILD new file mode 100644 index 000000000..43781fe50 --- /dev/null +++ b/v3.17/backports/cpp-httplib/APKBUILD @@ -0,0 +1,45 @@ +# Contributor: Florent Ferreri +# Maintainer: +pkgname=cpp-httplib +pkgver=0.17.3 +pkgrel=0 +pkgdesc="A C++ header-only HTTP/HTTPS server and client library" +url="https://github.com/yhirose/cpp-httplib" +arch="all" +license="MIT" +depends="" +makedepends="cmake curl-dev gmock gtest-dev" +subpackages="$pkgname-dev $pkgname-doc" +source="$pkgname-$pkgver.tar.gz::https://github.com/yhirose/cpp-httplib/archive/v$pkgver.tar.gz + fix-test-makefile.patch + disable-ipv6-related-tests.patch" + +builddir="$srcdir/$pkgname-$pkgver" + +build() { + cd "$builddir" + mkdir -p build && cd build + cmake \ + -DCMAKE_INSTALL_PREFIX=/usr \ + -DHTTPLIB_TEST=ON \ + -DCMAKE_BUILD_TYPE=Release \ + .. + make +} + +check() { + cd "$builddir"/test + make + make fuzz_test +} + +package() { + cd "$builddir"/build + make DESTDIR="$pkgdir" install + + install -Dm 0644 "$builddir"/LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE +} + +sha512sums="9ee144727470af8a9f6ba953e95227c534ec87c1c89a17d511bb763091336c106e8d3a5fd8d4bf2c2274da0a64d42fde77eb95fb166e59f44bbbe906b3d327ec cpp-httplib-0.17.3.tar.gz +6aacdb5e4cc1689cb196c3a1e71444ce84a4f5a4537658379774d5e03f6921af79b7de5eceac86779948d27eebb5d4920010d4099d5323025a63f48e94bbb5be fix-test-makefile.patch +98331dda9cd3ad0f6202e3ef763a8067eb4d7df2eff59dc4e55b57f66024ba21b3fd8551a8591ad96aa2ee973be46cff85d7cac887a0c7d1c9944d1af7689910 disable-ipv6-related-tests.patch" diff --git a/v3.17/backports/cpp-httplib/disable-ipv6-related-tests.patch b/v3.17/backports/cpp-httplib/disable-ipv6-related-tests.patch new file mode 100644 index 000000000..762ad2d9d --- /dev/null +++ b/v3.17/backports/cpp-httplib/disable-ipv6-related-tests.patch @@ -0,0 +1,15 @@ +diff --git a/test/test.cc b/test/test.cc +index e2ae142..8149213 100644 +--- a/test/test.cc ++++ b/test/test.cc +@@ -1752,7 +1752,9 @@ TEST(RedirectFromPageWithContent, Redirect) { + } + } + +-TEST(RedirectFromPageWithContentIP6, Redirect) { ++// Disable as the fix from https://github.com/yhirose/cpp-httplib/issues/1053 does not seem to solve the issue ++// when running the tests in Github workflow ++TEST(RedirectFromPageWithContentIP6, DISABLED_Redirect) { + Server svr; + + svr.Get("/1", [&](const Request & /*req*/, Response &res) { diff --git a/v3.17/backports/cpp-httplib/fix-test-makefile.patch b/v3.17/backports/cpp-httplib/fix-test-makefile.patch new file mode 100644 index 000000000..e0a8eac7e --- /dev/null +++ b/v3.17/backports/cpp-httplib/fix-test-makefile.patch @@ -0,0 +1,25 @@ +diff --git a/test/Makefile b/test/Makefile +index 96ebec9..c2753b3 100644 +--- a/test/Makefile ++++ b/test/Makefile +@@ -1,9 +1,7 @@ +-CXX = clang++ ++CXX = g++ + CXXFLAGS = -g -std=c++11 -I. -Wall -Wextra -Wtype-limits -Wconversion -Wshadow # -fno-exceptions -DCPPHTTPLIB_NO_EXCEPTIONS -fsanitize=address + +-PREFIX ?= $(shell brew --prefix) +- +-OPENSSL_DIR = $(PREFIX)/opt/openssl@3 ++OPENSSL_DIR = /usr + OPENSSL_SUPPORT = -DCPPHTTPLIB_OPENSSL_SUPPORT -I$(OPENSSL_DIR)/include -L$(OPENSSL_DIR)/lib -lssl -lcrypto + + ifneq ($(OS), Windows_NT) +@@ -15,7 +13,7 @@ endif + + ZLIB_SUPPORT = -DCPPHTTPLIB_ZLIB_SUPPORT -lz + +-BROTLI_DIR = $(PREFIX)/opt/brotli ++BROTLI_DIR = /usr + BROTLI_SUPPORT = -DCPPHTTPLIB_BROTLI_SUPPORT -I$(BROTLI_DIR)/include -L$(BROTLI_DIR)/lib -lbrotlicommon -lbrotlienc -lbrotlidec + + TEST_ARGS = gtest/gtest-all.cc gtest/gtest_main.cc $(OPENSSL_SUPPORT) $(ZLIB_SUPPORT) $(BROTLI_SUPPORT) -pthread -lcurl diff --git a/v3.20/backports/cpp-httplib/APKBUILD b/v3.20/backports/cpp-httplib/APKBUILD new file mode 100644 index 000000000..caed9ea67 --- /dev/null +++ b/v3.20/backports/cpp-httplib/APKBUILD @@ -0,0 +1,47 @@ +# Contributor: Florent Ferreri +# Maintainer: +pkgname=cpp-httplib +pkgver=0.17.3 +pkgrel=0 +pkgdesc="A C++ header-only HTTP/HTTPS server and client library" +url="https://github.com/yhirose/cpp-httplib" +arch="all" +license="MIT" +depends="" +makedepends="cmake curl-dev gmock gtest-dev" +subpackages="$pkgname-dev $pkgname-doc" +source="$pkgname-$pkgver.tar.gz::https://github.com/yhirose/cpp-httplib/archive/v$pkgver.tar.gz + fix-test-makefile.patch + disable-ipv6-related-tests.patch + disable-ssl-certificates-tests.patch" + +builddir="$srcdir/$pkgname-$pkgver" + +build() { + cd "$builddir" + mkdir -p build && cd build + cmake \ + -DCMAKE_INSTALL_PREFIX=/usr \ + -DHTTPLIB_TEST=ON \ + -DCMAKE_BUILD_TYPE=Release \ + .. + make +} + +check() { + cd "$builddir"/test + make + make fuzz_test +} + +package() { + cd "$builddir"/build + make DESTDIR="$pkgdir" install + + install -Dm 0644 "$builddir"/LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE +} + +sha512sums="9ee144727470af8a9f6ba953e95227c534ec87c1c89a17d511bb763091336c106e8d3a5fd8d4bf2c2274da0a64d42fde77eb95fb166e59f44bbbe906b3d327ec cpp-httplib-0.17.3.tar.gz +6aacdb5e4cc1689cb196c3a1e71444ce84a4f5a4537658379774d5e03f6921af79b7de5eceac86779948d27eebb5d4920010d4099d5323025a63f48e94bbb5be fix-test-makefile.patch +98331dda9cd3ad0f6202e3ef763a8067eb4d7df2eff59dc4e55b57f66024ba21b3fd8551a8591ad96aa2ee973be46cff85d7cac887a0c7d1c9944d1af7689910 disable-ipv6-related-tests.patch +8de98ea4b6d367c6df31d857620508695a3b6011aa289f64a4c05d4a7795a92138162edee7ebf42e7a5cc19b8af9e6b72b735bd1fb78c64cbfdd960509785850 disable-ssl-certificates-tests.patch" diff --git a/v3.20/backports/cpp-httplib/disable-ipv6-related-tests.patch b/v3.20/backports/cpp-httplib/disable-ipv6-related-tests.patch new file mode 100644 index 000000000..762ad2d9d --- /dev/null +++ b/v3.20/backports/cpp-httplib/disable-ipv6-related-tests.patch @@ -0,0 +1,15 @@ +diff --git a/test/test.cc b/test/test.cc +index e2ae142..8149213 100644 +--- a/test/test.cc ++++ b/test/test.cc +@@ -1752,7 +1752,9 @@ TEST(RedirectFromPageWithContent, Redirect) { + } + } + +-TEST(RedirectFromPageWithContentIP6, Redirect) { ++// Disable as the fix from https://github.com/yhirose/cpp-httplib/issues/1053 does not seem to solve the issue ++// when running the tests in Github workflow ++TEST(RedirectFromPageWithContentIP6, DISABLED_Redirect) { + Server svr; + + svr.Get("/1", [&](const Request & /*req*/, Response &res) { diff --git a/v3.20/backports/cpp-httplib/disable-ssl-certificates-tests.patch b/v3.20/backports/cpp-httplib/disable-ssl-certificates-tests.patch new file mode 100644 index 000000000..4eb301658 --- /dev/null +++ b/v3.20/backports/cpp-httplib/disable-ssl-certificates-tests.patch @@ -0,0 +1,56 @@ +diff --git a/test/test.cc b/test/test.cc +index e2ae142..ca18ae6 100644 +--- a/test/test.cc ++++ b/test/test.cc +@@ -5951,11 +5951,13 @@ void ClientCertPresent( + ASSERT_EQ(StatusCode::OK_200, res->status); + } + +-TEST(SSLClientServerTest, ClientCertPresent) { ++// Disable this test for now. See https://github.com/yhirose/cpp-httplib/issues/1798 ++TEST(SSLClientServerTest, DISABLED_ClientCertPresent) { + ClientCertPresent(CLIENT_CERT_FILE, CLIENT_PRIVATE_KEY_FILE); + } + +-TEST(SSLClientServerTest, ClientEncryptedCertPresent) { ++// Disable this test for now. See https://github.com/yhirose/cpp-httplib/issues/1798 ++TEST(SSLClientServerTest, DISABLED_ClientEncryptedCertPresent) { + ClientCertPresent(CLIENT_ENCRYPTED_CERT_FILE, + CLIENT_ENCRYPTED_PRIVATE_KEY_FILE, + CLIENT_ENCRYPTED_PRIVATE_KEY_PASS); +@@ -6039,11 +6041,13 @@ void MemoryClientCertPresent( + EVP_PKEY_free(client_private_key); + } + +-TEST(SSLClientServerTest, MemoryClientCertPresent) { ++// Disable this test for now. See https://github.com/yhirose/cpp-httplib/issues/1798 ++TEST(SSLClientServerTest, DISABLED_MemoryClientCertPresent) { + MemoryClientCertPresent(CLIENT_CERT_FILE, CLIENT_PRIVATE_KEY_FILE); + } + +-TEST(SSLClientServerTest, MemoryClientEncryptedCertPresent) { ++// Disable this test for now. See https://github.com/yhirose/cpp-httplib/issues/1798 ++TEST(SSLClientServerTest, DISABLED_MemoryClientEncryptedCertPresent) { + MemoryClientCertPresent(CLIENT_ENCRYPTED_CERT_FILE, + CLIENT_ENCRYPTED_PRIVATE_KEY_FILE, + CLIENT_ENCRYPTED_PRIVATE_KEY_PASS); +@@ -6073,7 +6077,8 @@ TEST(SSLClientServerTest, ClientCertMissing) { + EXPECT_EQ(Error::SSLServerVerification, res.error()); + } + +-TEST(SSLClientServerTest, TrustDirOptional) { ++// Disable this test for now. See https://github.com/yhirose/cpp-httplib/issues/1798 ++TEST(SSLClientServerTest, DISABLED_TrustDirOptional) { + SSLServer svr(SERVER_CERT_FILE, SERVER_PRIVATE_KEY_FILE, CLIENT_CA_CERT_FILE); + ASSERT_TRUE(svr.is_valid()); + +@@ -6147,7 +6152,8 @@ TEST(SSLClientServerTest, SSLConnectTimeout) { + EXPECT_EQ(Error::SSLConnection, res.error()); + } + +-TEST(SSLClientServerTest, CustomizeServerSSLCtx) { ++// Disable this test for now. See https://github.com/yhirose/cpp-httplib/issues/1798 ++TEST(SSLClientServerTest, DISABLED_CustomizeServerSSLCtx) { + auto setup_ssl_ctx_callback = [](SSL_CTX &ssl_ctx) { + SSL_CTX_set_options(&ssl_ctx, SSL_OP_NO_COMPRESSION); + SSL_CTX_set_options(&ssl_ctx, diff --git a/v3.20/backports/cpp-httplib/fix-test-makefile.patch b/v3.20/backports/cpp-httplib/fix-test-makefile.patch new file mode 100644 index 000000000..e0a8eac7e --- /dev/null +++ b/v3.20/backports/cpp-httplib/fix-test-makefile.patch @@ -0,0 +1,25 @@ +diff --git a/test/Makefile b/test/Makefile +index 96ebec9..c2753b3 100644 +--- a/test/Makefile ++++ b/test/Makefile +@@ -1,9 +1,7 @@ +-CXX = clang++ ++CXX = g++ + CXXFLAGS = -g -std=c++11 -I. -Wall -Wextra -Wtype-limits -Wconversion -Wshadow # -fno-exceptions -DCPPHTTPLIB_NO_EXCEPTIONS -fsanitize=address + +-PREFIX ?= $(shell brew --prefix) +- +-OPENSSL_DIR = $(PREFIX)/opt/openssl@3 ++OPENSSL_DIR = /usr + OPENSSL_SUPPORT = -DCPPHTTPLIB_OPENSSL_SUPPORT -I$(OPENSSL_DIR)/include -L$(OPENSSL_DIR)/lib -lssl -lcrypto + + ifneq ($(OS), Windows_NT) +@@ -15,7 +13,7 @@ endif + + ZLIB_SUPPORT = -DCPPHTTPLIB_ZLIB_SUPPORT -lz + +-BROTLI_DIR = $(PREFIX)/opt/brotli ++BROTLI_DIR = /usr + BROTLI_SUPPORT = -DCPPHTTPLIB_BROTLI_SUPPORT -I$(BROTLI_DIR)/include -L$(BROTLI_DIR)/lib -lbrotlicommon -lbrotlienc -lbrotlidec + + TEST_ARGS = gtest/gtest-all.cc gtest/gtest_main.cc $(OPENSSL_SUPPORT) $(ZLIB_SUPPORT) $(BROTLI_SUPPORT) -pthread -lcurl