Skip to the content.

🏠 Home | Next: Basic Usage >


Getting Started

To use cpp-http, include the cpphttp.hpp header in your project. It depends on cpp-tcpnet (the foundational network engine), which in turn depends on cpp-pubsub and cpp-asyncworker.

Integration

You can have CMake automatically download and integrate cpp-http and its dependencies.

include(FetchContent)

FetchContent_Declare(
  cpphttp
  GIT_REPOSITORY https://github.com/jonoton/cpp-http.git
  GIT_TAG main
)
FetchContent_MakeAvailable(cpphttp)

add_executable(my_app main.cpp)
target_link_libraries(my_app PRIVATE cpphttp::cpphttp)

By linking cpphttp::cpphttp, CMake will automatically set up the header include paths and pull in the dependencies (cpp-tcpnet, and by default, cpp-quic).

QUIC Support Configuration

By default, QUIC (HTTP/3) features are enabled (CPPHTTP_ENABLE_QUIC=ON). CMake will automatically fetch the dependency cpp-quic.

If you do not want to use QUIC and want to avoid downloading its dependencies, you can explicitly disable it before loading the package:

set(CPPHTTP_ENABLE_QUIC OFF CACHE BOOL "Disable QUIC support" FORCE)

When QUIC is disabled, the library runs in pure TCP/HTTPS mode without requiring any UDP/QUIC dependency libraries.

2. Manual Compilation (Without CMake)

If you are compiling manually without CMake, you will need to add all sibling library include folders to your header search path:

On Linux/macOS, you must link the pthread library. On Windows, socket libraries are handled automatically.

# Basic compilation command:
g++ -std=c++17 -pthread -I/path/to/cpp-http -I/path/to/cpp-tcpnet -I/path/to/cpp-pubsub -I/path/to/cpp-asyncworker main.cpp -o my_app

🏠 Home | Next: Basic Usage >