A high-performance web server, reverse proxy, load balancer, API gateway and content cache written in C.
yhirose/cpp-httplib
A C++11 single-header library for building HTTP/HTTPS servers and clients with blocking socket I/O.
- Stars
- 16,923
- Forks
- 2,777
- Open issues
- 0
- Last commit
- 17 hours ago
What is it?
cpp-httplib is a cross-platform C++11 library that provides both an HTTP/HTTPS server and client. It ships as a single header file, httplib.h, so adding it to a project only requires including that file. It uses blocking socket I/O and supports HTTP/1.1 only; HTTP/2 and HTTP/3 are not implemented.
The library covers routing with path parameters and regular expressions, static file serving with MIME mapping, multipart form and file uploads, chunked transfer and streaming content providers, keep-alive connections, and middleware-style hooks such as pre-routing, post-routing and exception handlers. Server-Sent Events and WebSocket are documented as additional features.
TLS is available through OpenSSL (3.0 or later), Mbed TLS, or wolfSSL, selected with a compile-time define. It also includes certificate verification controls, mutual TLS, and on macOS and Windows integration with the system certificate store.
Key features
- 01Single-header include with no build dependencies for basic HTTP use
- 02HTTP server and client in one library
- 03HTTPS via OpenSSL, Mbed TLS, or wolfSSL
- 04Routing with path parameters and regular expressions
- 05Static file serving, multipart uploads, and chunked or streamed responses
- 06Mutual TLS and certificate verification controls
Use cases
- Adding a lightweight embedded HTTP endpoint to a C++ application without pulling in a large framework
- Writing a C++ client that calls REST APIs over HTTPS
- Serving static files or simple web APIs from a C++ tool
- Prototyping a local HTTP service in a C++ project with minimal setup
Quick start
- 1
Download the httplib.h file from the repository
- 2
Include httplib.h in your C++ code and build a server or client as shown in the examples
Things to know
- Uses blocking socket I/O, so it is not suitable for non-blocking designs.
- Supports only HTTP/1.1; HTTP/2 and HTTP/3 are not implemented.
- 32-bit platforms are not supported and receive no security review.
Topics
FAQ
- What is cpp-httplib?
- A C++11 single-header library for building HTTP/HTTPS servers and clients with blocking socket I/O. cpp-httplib is a cross-platform C++11 library that provides both an HTTP/HTTPS server and client. It ships as a single header file, httplib.h, so adding it to a project only requires including that file. It uses blocking socket I/O and supports HTTP/1.1 only; HTTP/2 and HTTP/3 are not implemented.
- Is cpp-httplib free to use? What license does it have?
- cpp-httplib is open source under the MIT license. Check the license terms before using it in commercial products.
- Is cpp-httplib still maintained?
- Actively maintained. The last commit to cpp-httplib was on Oct 22, 2026.
- What can I use cpp-httplib for?
- Adding a lightweight embedded HTTP endpoint to a C++ application without pulling in a large framework Writing a C++ client that calls REST APIs over HTTPS Serving static files or simple web APIs from a C++ tool Prototyping a local HTTP service in a C++ project with minimal setup
- How do I install cpp-httplib?
- Download the httplib.h file from the repository Include httplib.h in your C++ code and build a server or client as shown in the examples
- Where can I get cpp-httplib?
- The source code and installation instructions are on GitHub: https://github.com/yhirose/cpp-httplib
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
Caddy is an extensible web server written in Go that serves HTTP/1.1, HTTP/2 and HTTP/3 and enables HTTPS automatically by default.
Fast HTTP server and client implementation for Go, designed for high-throughput workloads and low allocation overhead.
Header-only C++ library for fast, exact parsing of float, double and integer values from strings, a drop-in style from_chars implementation.
A fast, Flask-style C++ microframework for building HTTP and WebSocket web services, header-only and easy to use.
A high-performance, minimalist web framework for Go, built on the standard net/http package.