Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: yhirose/cpp-httplib
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.18.4
Choose a base ref
...
head repository: yhirose/cpp-httplib
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref

Commits on Jan 17, 2025

  1. Fix #2011

    yhirose committed Jan 17, 2025
    Copy the full SHA
    343a0fc View commit details
  2. Fix #2014

    yhirose committed Jan 17, 2025
    Copy the full SHA
    ba68459 View commit details
  3. Fix Windows build problem

    yhirose committed Jan 17, 2025
    Copy the full SHA
    8311e11 View commit details
  4. Resolve #2017 (#2022)

    * Resolve #2017
    
    * Fix warning
    
    * Update README
    yhirose authored Jan 17, 2025
    Copy the full SHA
    986a20f View commit details
  5. Release v0.18.5

    yhirose committed Jan 17, 2025
    Copy the full SHA
    3779800 View commit details

Commits on Jan 20, 2025

  1. Update README

    yhirose committed Jan 20, 2025
    Copy the full SHA
    ef5e404 View commit details
  2. Update README

    yhirose committed Jan 20, 2025
    Copy the full SHA
    3047183 View commit details
  3. Update copyright year

    yhirose committed Jan 20, 2025
    Copy the full SHA
    929dfbd View commit details

Commits on Jan 26, 2025

  1. Update httplib.h (#2030)

    fix 'max'
    baiyies authored Jan 26, 2025
    Copy the full SHA
    d69f144 View commit details

Commits on Jan 27, 2025

  1. Fix README example

    yhirose committed Jan 27, 2025
    Copy the full SHA
    9104054 View commit details

Commits on Jan 28, 2025

  1. Support building httplib.h on OpenVMS x86 systems (#2031)

    Modify for OpenVMS x86 C++. Make tests on OpenVMS currently not supported due to no cmake support.
    Changes tested on OpenVMS clang C++ and Fedora & GCC
    alex-cornford authored Jan 28, 2025
    Copy the full SHA
    60a1f00 View commit details

Commits on Feb 2, 2025

  1. Add a unit test

    yhirose committed Feb 2, 2025
    Copy the full SHA
    282f2fe View commit details

Commits on Feb 3, 2025

  1. Copy the full SHA
    9bbb474 View commit details

Commits on Feb 5, 2025

  1. Fix #2033 (#2039)

    yhirose authored Feb 5, 2025
    Copy the full SHA
    4941d5b View commit details

Commits on Feb 6, 2025

  1. Release v0.18.6

    yhirose committed Feb 6, 2025
    Copy the full SHA
    eb30f15 View commit details
  2. Fix #2042

    yhirose committed Feb 6, 2025
    Copy the full SHA
    708f860 View commit details

Commits on Feb 8, 2025

  1. Add unit test for #609

    yhirose committed Feb 8, 2025
    Copy the full SHA
    eb10c22 View commit details
  2. Refine when content is expected (#2044)

    Consider Content-Length and Transfer-Encoding headers when determining
    whether to expect content. Don't handle the HTTP/2 connection preface
    pseudo-method PRI.
    
    Fixes #2028.
    falbrechtskirchinger authored Feb 8, 2025
    Copy the full SHA
    7adbccb View commit details
  3. Release v0.18.7

    yhirose committed Feb 8, 2025
    Copy the full SHA
    5814e12 View commit details

Commits on Feb 9, 2025

  1. Fix test.yaml problem

    yhirose committed Feb 9, 2025
    Copy the full SHA
    8aad481 View commit details

Commits on Feb 10, 2025

  1. Fix #2034 (#2048)

    * Fix #2034
    
    * Fix build error
    
    * Adjust threshold
    
    * Add temporary debug prints
    
    * Adjust threshhold
    
    * Another threshold adjustment for macOS on GitHub Actions CI...
    
    * Performance improvement by avoiding unnecessary chrono access
    
    * More performance improvement to avoid unnecessary chrono access
    yhirose authored Feb 10, 2025
    1
    Copy the full SHA
    8a7c536 View commit details
  2. Copy the full SHA
    8e22a76 View commit details
  3. Copy the full SHA
    b397c76 View commit details

Commits on Feb 11, 2025

  1. Copy the full SHA
    a268d65 View commit details
  2. Copy the full SHA
    dd20342 View commit details
  3. Copy the full SHA
    1880693 View commit details
  4. Copy the full SHA
    d7c14b6 View commit details
  5. Copy the full SHA
    39a64fb View commit details

Commits on Feb 12, 2025

  1. Copy the full SHA
    b6ab843 View commit details

Commits on Feb 14, 2025

  1. ci: add abidiff workflow (#2054)

    This CI workflow checks ABI compatibility between the pushed commit and
    the latest tagged release, helping preventing accidental ABI breaks.
    
    Helps with #2043
    Tachi107 authored Feb 14, 2025
    Copy the full SHA
    bfa2f73 View commit details
  2. Copy the full SHA
    d74e4a7 View commit details
  3. Copy the full SHA
    3c4b960 View commit details
  4. Release v0.19.0

    yhirose authored Feb 14, 2025
    Copy the full SHA
    03cf43e View commit details

Commits on Feb 15, 2025

  1. Refactor setting socket options (#2053)

    Add detail::set_socket_opt() and detail::set_socket_opt_time() to avoid
    repetition of platform-specific code.
    falbrechtskirchinger authored Feb 15, 2025
    Copy the full SHA
    233f0fb View commit details

Commits on Feb 16, 2025

  1. Copy the full SHA
    985cd9f View commit details
  2. Copy the full SHA
    4cb8ff9 View commit details
  3. Add workflow_dispatch with Google Test filter and OS selection (#2056)

    * Add workflow_dispatch with Google Test filter
    
    Add the workflow_dispatch trigger to the test.yaml workflow. Includes an
    input for an optional Google Test filter pattern.
    
    * Add OS selection to workflow_dispatch
    
    * Fix wording
    falbrechtskirchinger authored Feb 16, 2025
    Copy the full SHA
    748f47b View commit details
  4. Detect additional CMake build failures (#2058)

    Add include_httplib.cc to the main test executable (already done in
    Makefile), and add include_windows_h.cc to the main test executable on
    Windows to test if including windows.h conflicts with httplib.h.
    falbrechtskirchinger authored Feb 16, 2025
    Copy the full SHA
    735e593 View commit details
  5. Copy the full SHA
    32bf5c9 View commit details

Commits on Feb 17, 2025

  1. Fix code inconsistently formatted and re-format (#2063)

    * Fix code inconsistently formatted by clang-format
    
    * Run clang-format
    falbrechtskirchinger authored Feb 17, 2025
    Copy the full SHA
    2996cec View commit details
  2. Add style check to workflow (#2062)

    * Add style check to workflow
    
    * Add example files to style check
    falbrechtskirchinger authored Feb 17, 2025
    Copy the full SHA
    574f5ce View commit details
  3. server_certificate_verifier extended to reuse built-in verifier (#2064)

    * server_certificate_verifier extended to reuse built-in verifier
    
    * code cleanup and SSLVerifierResponse enum clarification as per @falbrechtskirchinger comment
    
    * cleanup
    
    * clang-format
    
    * change local var verification_status_ declaration to auto
    
    * change local var verification_status_ to verification_status
    
    * clang-format
    
    * clang-format
    
    ---------
    
    Co-authored-by: UrosG <uros@ub330.net>
    urosg80 and UrosG authored Feb 17, 2025
    Copy the full SHA
    cdc2230 View commit details

Commits on Feb 18, 2025

  1. Make poll() the default (#2065)

    * Make poll() the default
    
    select() can still be enabled by defining CPPHTTPLIB_USE_SELECT.
    
    * Run tests with select() and poll()
    falbrechtskirchinger authored Feb 18, 2025
    Copy the full SHA
    6e73a63 View commit details
  2. Fix misspelled words

    yhirose committed Feb 18, 2025
    Copy the full SHA
    ada9704 View commit details
  3. Add *.dSYM to Makefile clean

    yhirose committed Feb 18, 2025
    Copy the full SHA
    321a86d View commit details
  4. Copy the full SHA
    dda2e00 View commit details

Commits on Feb 19, 2025

  1. Fix typo

    yhirose committed Feb 19, 2025
    Copy the full SHA
    d274c0a View commit details
  2. Copy the full SHA
    2b5d1ee View commit details
  3. Copy the full SHA
    5c0135f View commit details

Commits on Feb 20, 2025

  1. Max timeout test refactoring (#2071)

    * Simplify code
    
    * Adjust threshold
    yhirose authored Feb 20, 2025
    Copy the full SHA
    a4b2c61 View commit details
Showing with 37,459 additions and 25,531 deletions.
  1. +69 −0 .github/workflows/abidiff.yaml
  2. +6 −0 .github/workflows/cifuzz.yaml
  3. +108 −20 .github/workflows/test.yaml
  4. +1 −0 .gitignore
  5. +32 −1 CMakeLists.txt
  6. +1 −1 Dockerfile
  7. +27 −17 README.md
  8. +28 −13 benchmark/Makefile
  9. +1 −1 benchmark/{cpp-httplib-base → cpp-httplib-v18}/httplib.h
  10. 0 benchmark/{cpp-httplib-base → cpp-httplib-v18}/main.cpp
  11. +10,475 −0 benchmark/cpp-httplib-v19/httplib.h
  12. +12 −0 benchmark/cpp-httplib-v19/main.cpp
  13. +26 −5 cmake/httplibConfig.cmake.in
  14. +2 −2 docker/main.cc
  15. +1 −1 example/server_and_client.cc
  16. +1 −2 example/ssesvr.cc
  17. +705 −513 httplib.h
  18. +1 −1 test/CMakeLists.txt
  19. +38 −3 test/Makefile
  20. +5 −1 test/fuzzing/server_fuzzer.cc
  21. +0 −12,501 test/gtest/gtest-all.cc
  22. +0 −12,377 test/gtest/gtest.h
  23. +237 −0 test/gtest/include/gtest/gtest-assertion-result.h
  24. +345 −0 test/gtest/include/gtest/gtest-death-test.h
  25. +956 −0 test/gtest/include/gtest/gtest-matchers.h
  26. +218 −0 test/gtest/include/gtest/gtest-message.h
  27. +510 −0 test/gtest/include/gtest/gtest-param-test.h
  28. +1,048 −0 test/gtest/include/gtest/gtest-printers.h
  29. +248 −0 test/gtest/include/gtest/gtest-spi.h
  30. +190 −0 test/gtest/include/gtest/gtest-test-part.h
  31. +331 −0 test/gtest/include/gtest/gtest-typed-test.h
  32. +2,297 −0 test/gtest/include/gtest/gtest.h
  33. +279 −0 test/gtest/include/gtest/gtest_pred_impl.h
  34. +60 −0 test/gtest/include/gtest/gtest_prod.h
  35. +44 −0 test/gtest/include/gtest/internal/custom/README.md
  36. +37 −0 test/gtest/include/gtest/internal/custom/gtest-port.h
  37. +42 −0 test/gtest/include/gtest/internal/custom/gtest-printers.h
  38. +37 −0 test/gtest/include/gtest/internal/custom/gtest.h
  39. +306 −0 test/gtest/include/gtest/internal/gtest-death-test-internal.h
  40. +210 −0 test/gtest/include/gtest/internal/gtest-filepath.h
  41. +1,570 −0 test/gtest/include/gtest/internal/gtest-internal.h
  42. +956 −0 test/gtest/include/gtest/internal/gtest-param-util.h
  43. +116 −0 test/gtest/include/gtest/internal/gtest-port-arch.h
  44. +2,413 −0 test/gtest/include/gtest/internal/gtest-port.h
  45. +177 −0 test/gtest/include/gtest/internal/gtest-string.h
  46. +186 −0 test/gtest/include/gtest/internal/gtest-type-util.h
  47. +49 −0 test/gtest/src/gtest-all.cc
  48. +77 −0 test/gtest/src/gtest-assertion-result.cc
  49. +1,620 −0 test/gtest/src/gtest-death-test.cc
  50. +367 −0 test/gtest/src/gtest-filepath.cc
  51. +1,212 −0 test/gtest/src/gtest-internal-inl.h
  52. +98 −0 test/gtest/src/gtest-matchers.cc
  53. +1,394 −0 test/gtest/src/gtest-port.cc
  54. +553 −0 test/gtest/src/gtest-printers.cc
  55. +105 −0 test/gtest/src/gtest-test-part.cc
  56. +104 −0 test/gtest/src/gtest-typed-test.cc
  57. +6,795 −0 test/gtest/src/gtest.cc
  58. +2 −3 test/gtest/{ → src}/gtest_main.cc
  59. +6 −0 test/include_windows_h.cc
  60. +28 −0 test/make-shared-library.sh
  61. +676 −52 test/test.cc
  62. +16 −17 test/test_proxy.cc
  63. +1 −0 test/www/meson.build
  64. +4 −0 test/www/日本語Dir/meson.build
69 changes: 69 additions & 0 deletions .github/workflows/abidiff.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# SPDX-FileCopyrightText: 2025 Andrea Pappacoda <andrea@pappacoda.it>
# SPDX-License-Identifier: MIT

name: abidiff

on: [push, pull_request]

concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true

defaults:
run:
shell: sh

jobs:
abi:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
container:
image: debian:testing

steps:
- name: Install dependencies
run: apt -y --update install --no-install-recommends
abigail-tools
ca-certificates
g++
git
libbrotli-dev
libssl-dev
meson
pkg-config
python3
zlib1g-dev

- uses: actions/checkout@v4
with:
path: current

- uses: actions/checkout@v4
with:
path: previous
fetch-depth: 0

- name: Checkout previous
working-directory: previous
run: |
git switch master
git describe --tags --abbrev=0 master | xargs git checkout
- name: Build current
working-directory: current
run: |
meson setup --buildtype=debug -Dcpp-httplib_compile=true build
ninja -C build
- name: Build previous
working-directory: previous
run: |
meson setup --buildtype=debug -Dcpp-httplib_compile=true build
ninja -C build
- name: Run abidiff
run: abidiff
--headers-dir1 previous/build
--headers-dir2 current/build
previous/build/libcpp-httplib.so
current/build/libcpp-httplib.so
6 changes: 6 additions & 0 deletions .github/workflows/cifuzz.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
name: CIFuzz

on: [pull_request]

concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true

jobs:
Fuzzing:
runs-on: ubuntu-latest
128 changes: 108 additions & 20 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,85 @@
name: test

on: [push, pull_request]
on:
push:
pull_request:
workflow_dispatch:
inputs:
gtest_filter:
description: 'Google Test filter'
test_linux:
description: 'Test on Linux'
type: boolean
default: true
test_macos:
description: 'Test on MacOS'
type: boolean
default: true
test_windows:
description: 'Test on Windows'
type: boolean
default: true

concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true

env:
GTEST_FILTER: ${{ github.event.inputs.gtest_filter || '*' }}

jobs:
style-check:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
continue-on-error: true
steps:
- name: checkout
uses: actions/checkout@v4
- name: run style check
run: |
clang-format --version
cd test && make style_check
ubuntu:
runs-on: ubuntu-latest
if: >
(github.event_name == 'push') ||
(github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name) ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.test_linux == 'true')
strategy:
matrix:
config:
- arch_flags: -m32
arch_suffix: :i386
name: (32-bit)
- arch_flags:
arch_suffix:
name: (64-bit)
name: ubuntu ${{ matrix.config.name }}
steps:
- name: checkout
uses: actions/checkout@v4
- name: install libraries
run: sudo apt-get update && sudo apt-get install -y libbrotli-dev libcurl4-openssl-dev
run: |
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install -y libc6-dev${{ matrix.config.arch_suffix }} libstdc++-13-dev${{ matrix.config.arch_suffix }} \
libssl-dev${{ matrix.config.arch_suffix }} libcurl4-openssl-dev${{ matrix.config.arch_suffix }} \
zlib1g-dev${{ matrix.config.arch_suffix }} libbrotli-dev${{ matrix.config.arch_suffix }} \
libzstd-dev${{ matrix.config.arch_suffix }}
- name: build and run tests
run: cd test && make
run: cd test && make EXTRA_CXXFLAGS="${{ matrix.config.arch_flags }}"
- name: run fuzz test target
run: cd test && make fuzz_test
run: cd test && make EXTRA_CXXFLAGS="${{ matrix.config.arch_flags }}" fuzz_test

macos:
runs-on: macos-latest
if: >
(github.event_name == 'push') ||
(github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name) ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.test_macos == 'true')
steps:
- name: checkout
uses: actions/checkout@v4
@@ -27,6 +90,27 @@ jobs:

windows:
runs-on: windows-latest
if: >
(github.event_name == 'push') ||
(github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name) ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.test_windows == 'true')
strategy:
matrix:
config:
- with_ssl: false
compiled: false
run_tests: true
name: without SSL
- with_ssl: true
compiled: false
run_tests: true
name: with SSL
- with_ssl: false
compiled: true
run_tests: false
name: compiled
name: windows ${{ matrix.config.name }}
steps:
- name: Prepare Git for Checkout on Windows
run: |
@@ -42,24 +126,28 @@ jobs:
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
- name: Setup msbuild on windows
uses: microsoft/setup-msbuild@v2
- name: Install libraries
run: |
vcpkg install gtest curl zlib brotli
choco install openssl
- name: Configure CMake with SSL
run: cmake -B build -S . -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=${{ env.VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake -DHTTPLIB_TEST=ON -DHTTPLIB_REQUIRE_OPENSSL=ON -DHTTPLIB_REQUIRE_ZLIB=ON -DHTTPLIB_REQUIRE_BROTLI=ON
- name: Build with with SSL
run: cmake --build build --config Release
- name: Run tests with SSL
- name: Install vcpkg dependencies
run: vcpkg install gtest curl zlib brotli zstd
- name: Install OpenSSL
if: ${{ matrix.config.with_ssl }}
run: choco install openssl
- name: Configure CMake ${{ matrix.config.name }}
run: >
cmake -B build -S .
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_TOOLCHAIN_FILE=${{ env.VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake
-DHTTPLIB_TEST=ON
-DHTTPLIB_COMPILE=${{ matrix.config.compiled && 'ON' || 'OFF' }}
-DHTTPLIB_REQUIRE_ZLIB=ON
-DHTTPLIB_REQUIRE_BROTLI=ON
-DHTTPLIB_REQUIRE_ZSTD=ON
-DHTTPLIB_REQUIRE_OPENSSL=${{ matrix.config.with_ssl && 'ON' || 'OFF' }}
- name: Build ${{ matrix.config.name }}
run: cmake --build build --config Release -- /v:m /clp:ShowCommandLine
- name: Run tests ${{ matrix.config.name }}
if: ${{ matrix.config.run_tests }}
run: ctest --output-on-failure --test-dir build -C Release

- name: Configure CMake without SSL
run: cmake -B build-no-ssl -S . -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=${{ env.VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake -DHTTPLIB_TEST=ON -DHTTPLIB_REQUIRE_OPENSSL=ON -DHTTPLIB_REQUIRE_ZLIB=ON -DHTTPLIB_REQUIRE_BROTLI=ON
- name: Build without SSL
run: cmake --build build-no-ssl --config Release
- name: Run tests without SSL
run: ctest --output-on-failure --test-dir build-no-ssl -C Release
env:
VCPKG_ROOT: "C:/vcpkg"
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -23,6 +23,7 @@ test/test.xcodeproj/*/xcuser*
test/*.o
test/*.pem
test/*.srl
test/_build_*
work/
benchmark/server*

33 changes: 32 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -4,9 +4,11 @@
* HTTPLIB_USE_OPENSSL_IF_AVAILABLE (default on)
* HTTPLIB_USE_ZLIB_IF_AVAILABLE (default on)
* HTTPLIB_USE_BROTLI_IF_AVAILABLE (default on)
* HTTPLIB_USE_ZSTD_IF_AVAILABLE (default on)
* HTTPLIB_REQUIRE_OPENSSL (default off)
* HTTPLIB_REQUIRE_ZLIB (default off)
* HTTPLIB_REQUIRE_BROTLI (default off)
* HTTPLIB_REQUIRE_ZSTD (default off)
* HTTPLIB_USE_CERTS_FROM_MACOSX_KEYCHAIN (default on)
* HTTPLIB_COMPILE (default off)
* HTTPLIB_INSTALL (default on)
@@ -16,7 +18,7 @@
-------------------------------------------------------------------------------
After installation with Cmake, a find_package(httplib COMPONENTS OpenSSL ZLIB Brotli) is available.
After installation with Cmake, a find_package(httplib COMPONENTS OpenSSL ZLIB Brotli zstd) is available.
This creates a httplib::httplib target (if found and if listed components are supported).
It can be linked like so:
@@ -45,6 +47,7 @@
* HTTPLIB_IS_USING_OPENSSL - a bool for if OpenSSL support is enabled.
* HTTPLIB_IS_USING_ZLIB - a bool for if ZLIB support is enabled.
* HTTPLIB_IS_USING_BROTLI - a bool for if Brotli support is enabled.
* HTTPLIB_IS_USING_ZSTD - a bool for if ZSTD support is enabled.
* HTTPLIB_IS_USING_CERTS_FROM_MACOSX_KEYCHAIN - a bool for if support of loading system certs from the Apple Keychain is enabled.
* HTTPLIB_IS_COMPILED - a bool for if the library is compiled, or otherwise header-only.
* HTTPLIB_INCLUDE_DIR - the root path to httplib's header (e.g. /usr/include).
@@ -101,6 +104,8 @@ option(HTTPLIB_TEST "Enables testing and builds tests" OFF)
option(HTTPLIB_REQUIRE_BROTLI "Requires Brotli to be found & linked, or fails build." OFF)
option(HTTPLIB_USE_BROTLI_IF_AVAILABLE "Uses Brotli (if available) to enable Brotli decompression support." ON)
option(HTTPLIB_USE_CERTS_FROM_MACOSX_KEYCHAIN "Enable feature to load system certs from the Apple Keychain." ON)
option(HTTPLIB_REQUIRE_ZSTD "Requires ZSTD to be found & linked, or fails build." OFF)
option(HTTPLIB_USE_ZSTD_IF_AVAILABLE "Uses ZSTD (if available) to enable zstd support." ON)
# Defaults to static library
option(BUILD_SHARED_LIBS "Build the library as a shared library instead of static. Has no effect if using header-only." OFF)
if (BUILD_SHARED_LIBS AND WIN32 AND HTTPLIB_COMPILE)
@@ -153,6 +158,30 @@ elseif(HTTPLIB_USE_BROTLI_IF_AVAILABLE)
set(HTTPLIB_IS_USING_BROTLI ${Brotli_FOUND})
endif()

if(HTTPLIB_REQUIRE_ZSTD)
find_package(zstd)
if(NOT zstd_FOUND)
find_package(PkgConfig REQUIRED)
pkg_check_modules(zstd REQUIRED IMPORTED_TARGET libzstd)
add_library(zstd::libzstd ALIAS PkgConfig::zstd)
endif()
set(HTTPLIB_IS_USING_ZSTD TRUE)
elseif(HTTPLIB_USE_ZSTD_IF_AVAILABLE)
find_package(zstd QUIET)
if(NOT zstd_FOUND)
find_package(PkgConfig QUIET)
if(PKG_CONFIG_FOUND)
pkg_check_modules(zstd QUIET IMPORTED_TARGET libzstd)

if(TARGET PkgConfig::zstd)
add_library(zstd::libzstd ALIAS PkgConfig::zstd)
endif()
endif()
endif()
# Both find_package and PkgConf set a XXX_FOUND var
set(HTTPLIB_IS_USING_ZSTD ${zstd_FOUND})
endif()

# Used for default, common dirs that the end-user can change (if needed)
# like CMAKE_INSTALL_INCLUDEDIR or CMAKE_INSTALL_DATADIR
include(GNUInstallDirs)
@@ -227,6 +256,7 @@ target_link_libraries(${PROJECT_NAME} ${_INTERFACE_OR_PUBLIC}
$<$<BOOL:${HTTPLIB_IS_USING_BROTLI}>:Brotli::encoder>
$<$<BOOL:${HTTPLIB_IS_USING_BROTLI}>:Brotli::decoder>
$<$<BOOL:${HTTPLIB_IS_USING_ZLIB}>:ZLIB::ZLIB>
$<$<BOOL:${HTTPLIB_IS_USING_ZSTD}>:zstd::libzstd>
$<$<BOOL:${HTTPLIB_IS_USING_OPENSSL}>:OpenSSL::SSL>
$<$<BOOL:${HTTPLIB_IS_USING_OPENSSL}>:OpenSSL::Crypto>
)
@@ -236,6 +266,7 @@ target_compile_definitions(${PROJECT_NAME} ${_INTERFACE_OR_PUBLIC}
$<$<BOOL:${HTTPLIB_NO_EXCEPTIONS}>:CPPHTTPLIB_NO_EXCEPTIONS>
$<$<BOOL:${HTTPLIB_IS_USING_BROTLI}>:CPPHTTPLIB_BROTLI_SUPPORT>
$<$<BOOL:${HTTPLIB_IS_USING_ZLIB}>:CPPHTTPLIB_ZLIB_SUPPORT>
$<$<BOOL:${HTTPLIB_IS_USING_ZSTD}>:CPPHTTPLIB_ZSTD_SUPPORT>
$<$<BOOL:${HTTPLIB_IS_USING_OPENSSL}>:CPPHTTPLIB_OPENSSL_SUPPORT>
$<$<AND:$<PLATFORM_ID:Darwin>,$<BOOL:${HTTPLIB_IS_USING_OPENSSL}>,$<BOOL:${HTTPLIB_IS_USING_CERTS_FROM_MACOSX_KEYCHAIN}>>:CPPHTTPLIB_USE_CERTS_FROM_MACOSX_KEYCHAIN>
)
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ FROM yhirose4dockerhub/ubuntu-builder AS builder
WORKDIR /build
COPY httplib.h .
COPY docker/main.cc .
RUN g++ -std=c++23 -static -o server -O2 -I. -DCPPHTTPLIB_USE_POLL main.cc && strip server
RUN g++ -std=c++23 -static -o server -O2 -I. main.cc && strip server

FROM scratch
COPY --from=builder /build/server /server
Loading