From bfa598f3c61b1654632b993fb212bca121bbf29c Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Sat, 20 Sep 2025 06:58:04 +0200 Subject: [PATCH 1/8] Allow disabling PSL --- CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6e79f354c..59924b9b9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,7 +56,8 @@ cpr_option(CPR_CURL_NOSIGNAL "Set to ON to disable use of signals in libcurl." O cpr_option(CURL_VERBOSE_LOGGING "Curl verbose logging during building curl" OFF) cpr_option(CPR_USE_SYSTEM_GTEST "If ON, this project will look in the system paths for an installed gtest library. If none is found it will use the built-in one." OFF) cpr_option(CPR_USE_SYSTEM_CURL "If enabled we will use the curl lib already installed on this system." OFF) -cpr_option(CPR_USE_SYSTEM_LIB_PSL "Since curl 8.13 it depends on libpsl. If enabled we will use the psl lib already installed on this system. Else meson is required as build dependency." ${CPR_USE_SYSTEM_CURL}) +cpr_option(CPR_CURL_USE_LIBPSL "Since curl 8.13 curl depends on libpsl (https://everything.curl.dev/build/deps.html#libpsl). By default cpr keeps this as a secure default enabled wich in turn requires meson as build dependency. If set to OFF, psl support inside curl will be disabled." OFF) +cpr_option(CPR_USE_SYSTEM_LIB_PSL "If enabled we will use the psl lib already installed on this system. Else meson is required as build dependency. Only relevant in case 'CPR_CURL_USE_LIBPSL' is set to ON." ${CPR_USE_SYSTEM_CURL}) cpr_option(CPR_ENABLE_CURL_HTTP_ONLY "If enabled we will only use the HTTP/HTTPS protocols from CURL. If disabled, all the CURL protocols are enabled. This is useful if your project uses libcurl and you need support for other CURL features e.g. sending emails." ON) cpr_option(CPR_ENABLE_SSL "Enables or disables the SSL backend. Required to perform HTTPS requests." ON) cpr_option(CPR_FORCE_OPENSSL_BACKEND "Force to use the OpenSSL backend. If CPR_FORCE_OPENSSL_BACKEND, CPR_FORCE_DARWINSSL_BACKEND, CPR_FORCE_MBEDTLS_BACKEND, and CPR_FORCE_WINSSL_BACKEND are set to to OFF, cpr will try to automatically detect the best available SSL backend (WinSSL - Windows, OpenSSL - Linux, DarwinSSL - Mac ...)." OFF) @@ -297,7 +298,8 @@ else() endif() # Since curl 8.13, curl depends on lib psl - if(NOT ${CPR_USE_SYSTEM_LIB_PSL}) + set(CURL_USE_LIBPSL ${CPR_CURL_USE_LIBPSL} CACHE INTERNAL "" FORCE) + if(CPR_CURL_USE_LIBPSL AND NOT CPR_USE_SYSTEM_LIB_PSL) include(libpsl) endif() From 361644bf29424d0b9d09bf2d7c69ea1a73c50fd4 Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Sat, 20 Sep 2025 07:20:00 +0200 Subject: [PATCH 2/8] Updated build requirements --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b10a2382e..a4679eecc 100644 --- a/README.md +++ b/README.md @@ -218,10 +218,11 @@ On FreeBSD, you can issue `pkg install cpr` or use the Ports tree to install it. The only explicit requirements are: -* a `C++17` compatible compiler such as Clang or GCC. The minimum required version of GCC is unknown, so if anyone has trouble building this library with a specific version of GCC, do let us know -* in case you only have a `C++11` compatible compiler available, all versions below cpr 1.9.x are for you. The 1.10.0 release of cpr switches to `C++17` as a requirement. +* A `C++17` compatible compiler such as Clang or GCC. The minimum required version of GCC is unknown, so if anyone has trouble building this library with a specific version of GCC, do let us know. +* In case you only have a `C++11` compatible compiler available, all versions below cpr 1.9.x are for you. The 1.10.0 release of cpr switches to `C++17` as a requirement. * If you would like to perform https requests `OpenSSL` and its development libraries are required. -* If you do not use the built-in version of [curl](https://github.com/curl/curl) but instead use your systems version, make sure you use a version `>= 7.64.0`. Lower versions are not supported. This means you need Debian `>= 10` or Ubuntu `>= 20.04 LTS`. +* If you do not use the built-in version of [curl](https://github.com/curl/curl) but instead use your systems version, make sure you use a version `>= 7.71.0`. Lower versions are not supported. This means you need Debian `>= 11` or Ubuntu `>= 22.04 LTS`. +* [`The Meson Build System`](https://mesonbuild.com/) is required for [PSL support for curl](https://everything.curl.dev/build/deps.html#libpsl). ## Building cpr - Using vcpkg From 5a03e7df426ef6580cd65a600ea4a0829f7da0da Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Sat, 20 Sep 2025 07:33:20 +0200 Subject: [PATCH 3/8] Added a CI run to check builds where PSL is disabled --- .github/workflows/ci.yml | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 886b5d3fd..1586c3996 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -120,7 +120,7 @@ jobs: - name: Update package list run: dnf update -y - name: Install Dependencies - run: dnf install -y gcc clang git gcc gdb make openssl-devel libcurl-devel cmake libpsl-devel libunistring-devel meson + run: dnf install -y gcc clang git make openssl-devel libcurl-devel cmake libpsl-devel libunistring-devel meson - name: Checkout uses: actions/checkout@v5 - name: "Build & Test" @@ -150,7 +150,7 @@ jobs: - name: Update package list run: dnf update -y - name: Install Dependencies - run: dnf install -y gcc clang git gcc gdb make openssl-devel libcurl-devel cmake libpsl-devel libunistring-devel meson + run: dnf install -y gcc clang git make openssl-devel libcurl-devel cmake libpsl-devel libunistring-devel meson - name: Checkout uses: actions/checkout@v5 - name: "Build & Test" @@ -169,6 +169,33 @@ jobs: run-test: true ctest-options: ${{ env.CTEST_OPTIONS }} + fedora-gcc-openssl-no-psl: + runs-on: ubuntu-latest + container: "fedora:latest" + steps: + - name: Update package list + run: dnf update -y + - name: Install Dependencies + run: dnf install -y git gcc make openssl-devel cmake libunistring-devel + - name: Checkout + uses: actions/checkout@v5 + - name: "Build & Test" + env: + CPR_BUILD_TESTS: ON + CPR_BUILD_TESTS_SSL: ON + CPR_FORCE_OPENSSL_BACKEND: ON + CPR_USE_SYSTEM_CURL: OFF + CPR_CURL_USE_LIBPSL: OFF + uses: ashutoshvarma/action-cmake-build@master + with: + build-dir: ${{ github.workspace }}/build + source-dir: ${{ github.workspace }} + cc: gcc + cxx: g++ + build-type: release + run-test: true + ctest-options: ${{ env.CTEST_OPTIONS }} + fedora-gcc-ssl-sanitizer: strategy: matrix: @@ -179,7 +206,7 @@ jobs: - name: Update package list run: dnf update -y - name: Install Dependencies - run: dnf install -y gcc clang git gcc gdb make openssl-devel libasan libubsan liblsan libtsan cmake libpsl-devel libunistring-devel meson + run: dnf install -y gcc clang git make openssl-devel libasan libubsan liblsan libtsan cmake libpsl-devel libunistring-devel meson - name: Checkout uses: actions/checkout@v5 - name: "Build & Test" From 3e37f8915ab569b1b5b45293bbbdecb2388a427b Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Sun, 21 Sep 2025 11:03:37 +0200 Subject: [PATCH 4/8] Enable PSL by default --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 59924b9b9..61b05c4f1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,7 +56,7 @@ cpr_option(CPR_CURL_NOSIGNAL "Set to ON to disable use of signals in libcurl." O cpr_option(CURL_VERBOSE_LOGGING "Curl verbose logging during building curl" OFF) cpr_option(CPR_USE_SYSTEM_GTEST "If ON, this project will look in the system paths for an installed gtest library. If none is found it will use the built-in one." OFF) cpr_option(CPR_USE_SYSTEM_CURL "If enabled we will use the curl lib already installed on this system." OFF) -cpr_option(CPR_CURL_USE_LIBPSL "Since curl 8.13 curl depends on libpsl (https://everything.curl.dev/build/deps.html#libpsl). By default cpr keeps this as a secure default enabled wich in turn requires meson as build dependency. If set to OFF, psl support inside curl will be disabled." OFF) +cpr_option(CPR_CURL_USE_LIBPSL "Since curl 8.13 curl depends on libpsl (https://everything.curl.dev/build/deps.html#libpsl). By default cpr keeps this as a secure default enabled wich in turn requires meson as build dependency. If set to OFF, psl support inside curl will be disabled." ON) cpr_option(CPR_USE_SYSTEM_LIB_PSL "If enabled we will use the psl lib already installed on this system. Else meson is required as build dependency. Only relevant in case 'CPR_CURL_USE_LIBPSL' is set to ON." ${CPR_USE_SYSTEM_CURL}) cpr_option(CPR_ENABLE_CURL_HTTP_ONLY "If enabled we will only use the HTTP/HTTPS protocols from CURL. If disabled, all the CURL protocols are enabled. This is useful if your project uses libcurl and you need support for other CURL features e.g. sending emails." ON) cpr_option(CPR_ENABLE_SSL "Enables or disables the SSL backend. Required to perform HTTPS requests." ON) From 547758f75a3fea72092b73f4e527e780ca51929a Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Sun, 21 Sep 2025 13:20:59 +0200 Subject: [PATCH 5/8] Added the missing g++ --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1586c3996..9788ee703 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -120,7 +120,7 @@ jobs: - name: Update package list run: dnf update -y - name: Install Dependencies - run: dnf install -y gcc clang git make openssl-devel libcurl-devel cmake libpsl-devel libunistring-devel meson + run: dnf install -y gcc g++ clang git make openssl-devel libcurl-devel cmake libpsl-devel libunistring-devel meson - name: Checkout uses: actions/checkout@v5 - name: "Build & Test" @@ -150,7 +150,7 @@ jobs: - name: Update package list run: dnf update -y - name: Install Dependencies - run: dnf install -y gcc clang git make openssl-devel libcurl-devel cmake libpsl-devel libunistring-devel meson + run: dnf install -y gcc g++ clang git make openssl-devel libcurl-devel cmake libpsl-devel libunistring-devel meson - name: Checkout uses: actions/checkout@v5 - name: "Build & Test" @@ -206,7 +206,7 @@ jobs: - name: Update package list run: dnf update -y - name: Install Dependencies - run: dnf install -y gcc clang git make openssl-devel libasan libubsan liblsan libtsan cmake libpsl-devel libunistring-devel meson + run: dnf install -y gcc g++ clang git make openssl-devel libasan libubsan liblsan libtsan cmake libpsl-devel libunistring-devel meson - name: Checkout uses: actions/checkout@v5 - name: "Build & Test" From 6b3597968fc4a4fc47e9e0a056198c41ebccfbbe Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Sun, 21 Sep 2025 13:32:00 +0200 Subject: [PATCH 6/8] Extended the PSL requirements docs --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a4679eecc..154760140 100644 --- a/README.md +++ b/README.md @@ -222,7 +222,7 @@ The only explicit requirements are: * In case you only have a `C++11` compatible compiler available, all versions below cpr 1.9.x are for you. The 1.10.0 release of cpr switches to `C++17` as a requirement. * If you would like to perform https requests `OpenSSL` and its development libraries are required. * If you do not use the built-in version of [curl](https://github.com/curl/curl) but instead use your systems version, make sure you use a version `>= 7.71.0`. Lower versions are not supported. This means you need Debian `>= 11` or Ubuntu `>= 22.04 LTS`. -* [`The Meson Build System`](https://mesonbuild.com/) is required for [PSL support for curl](https://everything.curl.dev/build/deps.html#libpsl). +* [`The Meson Build System`](https://mesonbuild.com/) is required build PSL from source ([PSL support for curl](https://everything.curl.dev/build/deps.html#libpsl)). For more information take a look at the `CPR_CURL_USE_LIBPSL` and `CPR_USE_SYSTEM_LIB_PSL` CMake options. ## Building cpr - Using vcpkg From 1ed7489b84e6acade9ae1fbbe46dfe010bc0ca2c Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Sun, 21 Sep 2025 17:01:01 +0200 Subject: [PATCH 7/8] Use a definitely wrong URL for proxy error tests --- test/error_tests.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/error_tests.cpp b/test/error_tests.cpp index 0656b91da..c8a5fbce6 100644 --- a/test/error_tests.cpp +++ b/test/error_tests.cpp @@ -73,7 +73,7 @@ TEST(ErrorTests, LowSpeedBytesFailure) { TEST(ErrorTests, ProxyFailure) { Url url{server->GetBaseUrl() + "/hello.html"}; - Response response = cpr::Get(url, cpr::Proxies{{"http", "http://bad_host.libcpr.org"}}); + Response response = cpr::Get(url, cpr::Proxies{{"http", "http://bad_host.libcpr.orgoooo"}}); EXPECT_EQ(url, response.url); EXPECT_EQ(0, response.status_code); // Sometimes the DNS server returns a fake address instead of an NXDOMAIN response, leading to COULDNT_CONNECT. From 836d4040aac7a61030791269f70b3b4bc36b7bda Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Sun, 21 Sep 2025 17:05:35 +0200 Subject: [PATCH 8/8] CI: Added missing g++ --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9788ee703..fe5238384 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -176,7 +176,7 @@ jobs: - name: Update package list run: dnf update -y - name: Install Dependencies - run: dnf install -y git gcc make openssl-devel cmake libunistring-devel + run: dnf install -y git gcc g++ make openssl-devel cmake libunistring-devel - name: Checkout uses: actions/checkout@v5 - name: "Build & Test" @@ -382,4 +382,4 @@ jobs: cxx: clang++ build-type: Release run-test: true - ctest-options: ${{ env.CTEST_OPTIONS }} \ No newline at end of file + ctest-options: ${{ env.CTEST_OPTIONS }}