diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 886b5d3fd..fe5238384 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 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 gcc gdb 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" @@ -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 g++ 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 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" @@ -355,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 }} diff --git a/CMakeLists.txt b/CMakeLists.txt index 6e79f354c..61b05c4f1 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." 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) 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() diff --git a/README.md b/README.md index b10a2382e..154760140 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 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 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.