https://github.com/paul-caron/curling
A C++ libcurl wrapper
https://github.com/paul-caron/curling
cpp17 curl easy header-only http-client libcurl mit-license modern-cpp rest-api shared-library
Last synced: 2 months ago
JSON representation
A C++ libcurl wrapper
- Host: GitHub
- URL: https://github.com/paul-caron/curling
- Owner: paul-caron
- License: mit
- Created: 2025-06-24T03:10:29.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-07-01T18:18:00.000Z (about 1 year ago)
- Last Synced: 2025-07-01T18:23:15.739Z (about 1 year ago)
- Topics: cpp17, curl, easy, header-only, http-client, libcurl, mit-license, modern-cpp, rest-api, shared-library
- Language: C++
- Homepage:
- Size: 2.15 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README


[](https://github.com/paul-caron/curling/actions/workflows/build-and-test.yml)


# ๐ Curling
Curling is a modern C++17 wrapper around libcurl, designed to simplify HTTP/HTTPS requests using a clean, fluent API.
It supports JSON payloads, file uploads, cookie management, authentication, proxy configuration, and more โ all with a RAII-safe design using smart pointers.
---
## ๐ Table of Contents
- [โจ Features](#-features)
- [๐ Installation](#-installation)
- [๐ Basic Usage](#-basic-usage)
- [โ
Example Test Case](#-example-test-case)
- [๐ง Internals & Design](#-internals--design)
- [๐ค Why Curling?](#-why-curling)
- [โ๏ธ Comparisons](#๏ธ-comparisons-with-other-popular-c-libcurl-wrappers)
- [๐ Documentation](#-documentation)
- [๐งช Testing](#-testing)
- [๐ค Contributing](#-contributing)
- [๐ License](#-license)
- [๐ค Maintainer](#-maintainer)
- [๐ Notes](#-notes)
---
## โจ Features
- ๐ **Fluent API** โ chainable and expressive request building
- ๐ค **Multipart and MIME support** โ for multipart forms and file uploads
- ๐ช **Cookie management** โ with optional persistent storage
- ๐ก **Proxy and authentication support** โ including Basic, Bearer, and Digest
- ๐ **Full HTTP verb support** โ GET, POST, PUT, DELETE, PATCH, HEAD
- ๐ **HTTP/2 and HTTP/3 support** โ via libcurl
- โณ **Progress callback support** โ for monitoring request progress
- ๐งฉ **Header-only library** โ just include and go
- ๐ฆ **.deb packaging** โ for easy installation on Debian-based systems
- ๐งช **CI-tested** โ with [Doctest](https://github.com/doctest/doctest) and GitHub Actions
---
## ๐ Installation
### ๐ง Build shared library
```bash
make
```
To install and package as a Debian .deb:
```bash
make install
make deb
```
Install it locally:
```bash
sudo apt install ./curling_1.0_amd64.deb
sudo ldconfig
```
### ๐ชถ Header-only version
```bash
make header-only
```
This produces a header-only version in:
`curling/header-only/`
---
## ๐ Basic Usage
```cpp
#include "curling.hpp"
#include
int main() {
curling::Request req;
auto res = req.setMethod(curling::Request::Method::GET)
.setURL("https://example.com")
.setUserAgent("Lizardzilla/6.9 (Reptilian Humanoid)")
.send();
std::cout << res.toString();
return 0;
}
```
### ๐จ Compile
With shared library:
```bash
g++ main.cpp -lcurling -std=c++17
```
With header-only:
```bash
g++ main.cpp -lcurl -std=c++17
```
---
## โ
Example Test Case
Tests run automatically on every push via GitHub Actions.
```cpp
TEST_CASE("GET request to download image") {
curling::Request req;
req.setURL("https://httpbin.org/image/png")
.downloadToFile("out.png");
auto res = req.send();
CHECK(res.httpCode == 200);
CHECK(std::filesystem::exists("out.png"));
}
```
Run tests locally:
```bash
make test
```
---
## ๐ง Design Philosophy
Curling centers around the curling::Request class, which wraps libcurl functionality in a fluent, type-safe, modern C++ API.
Key principles:
- โ
RAII & smart pointers โ automatic resource cleanup
- โ
Fluent chaining โ readable and efficient method calls
- โ
No global state โ avoids curl_global_* leaks
- โ
Safe-by-default โ redirects off by default, verbose off, etc.
---
## ๐ค Why Curling?
Libcurl is powerful, but its C API is verbose and error-prone.
Curling offers:
|Feature |libcurl |Curling|
|------------------------|-----------|-------|
|Fluent C++ API |โ |โ
|
|RAII memory management |โ |โ
|
|Built-in test coverage |โ |โ
|
|Easy file & MIME upload |Manual |โ
|
|Modern build integration|โ |โ
|
---
## โ๏ธ Comparisons with Other Popular C++ libcurl Wrappers
Curling aims to strike a balance between modern C++ design, fine-grained control, and ease of use. Here's how it compares to other popular libcurl wrappers:
| Aspect | CPR | curlpp | Curling (this project) |
|---------------------|-------------------------------|-----------------------------|--------------------------------------------|
| API Style | High-level, intuitive | Classic wrapper, less modern| Modern C++17 fluent API with chaining |
| Abstraction Level | Heavy abstraction, hides internals | Moderate abstraction, outdated | Balanced abstraction, exposes fine control|
| Memory Management | Manual (raw pointers internally) | Manual | RAII with smart pointers |
| Feature Completeness| Common HTTP (GET/POST/JSON/auth)| Full libcurl coverage, less ergonomic | Full HTTP verbs, MIME, advanced auth |
| File/MIME Upload | Partial support, verbose | Supported, clunky | Fully integrated, fluent MIME support |
| Authentication | Basic, Bearer | Basic, Digest | Basic, Bearer, Digest (incl. SHA-256) |
| Build & Packaging | Shared/static via CMake | Static/shared library | Header-only mode + Debian `.deb` packaging |
| Test Coverage | Minimal | Minimal | Full coverage with Doctest + CI |
| Thread Safety | Not guaranteed | Not guaranteed | Not thread-safe (documented) |
| Customization | Limited | Moderate | Extensive fine-tuned libcurl control |
| Docs & Examples | Good docs, simple examples | Sparse | Rich examples + auto-generated Doxygen docs|
| Community | Active, popular | Aging, low activity | Growing with CI, automation, and tests |
### Why Choose Curling Over CPR or curlpp?
More control, less complexity: Full access to advanced libcurl options via a modern interface.
RAII-safe: Automatic cleanup prevents memory and resource leaks.
Rich MIME and auth support: Complex uploads and multiple authentication schemes are built-in.
Flexible builds: Choose between header-only use or .deb packages for installation.
CI and tests: Every commit is tested, ensuring high reliability.
Safe defaults: Redirects and verbose logging are disabled by default, encouraging secure usage.
---
## ๐ Documentation
Generate API documentation with Doxygen:
```bash
make doc
```
HTML output will appear in the doc/ folder.
To clean:
```bash
make doc-clean
```
---
## ๐งช Testing
Tests use Doctest and cover:
- โ
HTTP verbs: GET, POST, PUT, PATCH, DELETE, MIME
- โ
Authentication: Basic, Bearer, Digest (MD5, SHA-256, auth-int)
- โ
File download and upload
- โ
Header manipulation
- โ
JSON and form-data handling
- โ
Redirect handling
Run locally:
```bash
make test
```
GitHub Actions ensures tests pass on every push and pull request.
---
## ๐ค Contributing
Contributions are welcome! Please:
Format code consistently
Run make test before pushing
Use atomic and focused commits
---
## ๐ License
This project is licensed under the MIT License.
---
## ๐ค Maintainer
Paul Caron
---
## ๐ Notes
Curl global init/cleanup is handled automatically.
Not thread-safe โ avoid sharing curling::Request across threads.
MIME is a distinct HTTP method type (not used with POST/PUT).
---