libchttpx is a compact cross-platform HTTP/1.1 server library for C. It provides an App-based runtime, routing, middleware, request parsing, JSON binding and responses, uploads, request-scoped memory, CORS, cookies, i18n, logging, rate limiting, and graceful shutdown while keeping a direct C-style API.
The library is designed so handlers contain application logic instead of repetitive HTTP plumbing.
- Linux and Windows support
- multiple independent HTTP servers inside one
cHTTPX_App - local direct server-to-server calls and remote HTTP/HTTPS calls
- route groups and
{parameter}paths - global, router, and route middleware with before/after phases
- typed path/query accessors and URL decoding
- request-scoped allocation, deferred cleanup, and named contexts
- JSON parsing, validation, normalization, binding, and builder responses
- multipart forms, multiple uploads, upload policies, and temporary-file cleanup
- request IDs and
Accept-Languagenegotiation - CORS, cookies, logging callbacks, and rate limiting
- configurable gzip response compression with
Accept-Encodingnegotiation - optional built-in metrics with thread-safe snapshots and a Prometheus exporter
- configurable server limits and graceful shutdown
cHTTPX_ResFile()currently reads the complete file into memory. Streaming responses,sendfile(), and zero-copy output are not implemented in the current API.
For Debian/Ubuntu on amd64, add the libchttpx APT repository once:
curl -fsSL https://netcorelink.github.io/libchttpx/apt/libchttpx.sources \
| sudo tee /etc/apt/sources.list.d/libchttpx.sources >/dev/null
sudo apt update
sudo apt install libchttpx-devAfter that, libchttpx updates are installed through the normal APT flow:
sudo apt update
sudo apt upgradeRemove the package:
sudo apt remove libchttpx-devRemove the repository itself:
sudo rm /etc/apt/sources.list.d/libchttpx.sources
sudo apt updateThe current repository uses Trusted: yes, so users do not need to install a separate GPG key. Package signing can be added later.
Compile an application after installation:
gcc server.c -o server $(pkg-config --cflags --libs libchttpx)Native packages are also attached to GitHub Releases:
Fedora / RHEL and compatible RPM distributions
sudo dnf install ./libchttpx-dev-*.rpmArch Linux
sudo pacman -U ./libchttpx-dev-*.pkg.tar.zstAlpine Linux
sudo apk add --allow-untrusted ./libchttpx-dev_*.apkDownload the package for your distribution from GitHub Releases.
The existing shell and PowerShell installers are kept as compatibility fallbacks.
Linux:
curl -s https://raw.githubusercontent.com/netcorelink/libchttpx/main/scripts/install.sh | sudo shWindows:
iwr https://raw.githubusercontent.com/netcorelink/libchttpx/main/scripts/install.ps1 -UseBasicParsing | iexRestart the terminal after the Windows installation so environment changes are visible.
Pull the published runtime image:
docker pull noneandundefined/libchttpx:latestThe image contains the installed shared library, headers, pkg-config metadata, and the cJSON runtime.
FROM noneandundefined/libchttpx:latest
COPY my-server /usr/local/bin/my-server
CMD ["/usr/local/bin/my-server"]Requirements: GCC, Make, pkg-config, cJSON development files, and zlib development files.
sudo apt update
sudo apt install -y build-essential pkg-config libcjson-dev zlib1g-dev
git clone https://github.com/netcorelink/libchttpx.git
cd libchttpx
make lin-lib
sudo make lib-install PREFIX=/usr/local DESTDIR=Tests:
make test
make test-sanitizeOptional native TLS/HTTPS support uses OpenSSL and does not affect the default plain HTTP build:
sudo apt install -y libssl-dev openssl
make TLS=1 libchttpx.so
make test-tlsSee Native TLS / HTTPS for server certificates, HTTPS remote calls, custom CA verification, and mTLS.
Response compression is included in the standard build. zlib is a normal libchttpx dependency; applications enable compression at runtime with cHTTPX_CompressionUse() and configure minimum size, level, MIME policy, or custom providers in code.
make test-compressionTLS remains independently optional: make TLS=1 libchttpx.so. See Response compression.
Use MinGW/GCC. The Windows build uses the bundled lib/cjson source and requires zlib (for MSYS2/MinGW64: mingw-w64-x86_64-zlib).
git clone https://github.com/netcorelink/libchttpx.git
cd libchttpx
make win-lib
make test-winThe generated DLL/import library and headers are copied into tools/.
Detailed documentation is split by functionality:
- Documentation index
- App runtime, multiple servers, AppRemote, Call and CallEx
- Server configuration, limits, lifecycle and error codes
- Native TLS / HTTPS
- Response compression
- Metrics and Prometheus exporter
- Routing and route groups
- Middleware
- Requests, headers, params, queries and body access
- Responses and ownership
- JSON binding, validation and JSON builder
- Request-scoped memory and contexts
- Uploads, multipart forms and MIME helpers
- CORS
- Cookies
- Request IDs and i18n
- Logging
- Rate limiting
- WebSocket API — experimental
BSD 3-Clause. See LICENSE.