diff options
| author | Stefan Boberg <[email protected]> | 2026-04-09 11:02:41 +0200 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2026-04-09 11:02:41 +0200 |
| commit | 5900f6a6d892fbe582c46063cc399a840e60ef2e (patch) | |
| tree | 76735ff6de39c2c515a866ecc9d7b4309d63669d /docs/dev/VersioningCompatibility.md | |
| parent | migrate from http_parser to llhttp (#929) (diff) | |
| download | zen-5900f6a6d892fbe582c46063cc399a840e60ef2e.tar.xz zen-5900f6a6d892fbe582c46063cc399a840e60ef2e.zip | |
Add async HTTP client (curl_multi + ASIO) (#918)
- Adds `AsyncHttpClient` — an asynchronous HTTP client using `curl_multi_socket_action` integrated with ASIO for event-driven I/O. Supports GET, POST, PUT, DELETE, HEAD with both callback-based and `std::future`-based APIs.
- Extracts shared curl helpers (callbacks, URL encoding, header construction, error mapping) into `httpclientcurlhelpers.h`, eliminating duplication between the sync and async implementations.
## Design
- All curl_multi state is serialized on an `asio::strand`, safe with multi-threaded io_contexts.
- Two construction modes: owned io_context (creates internal thread) or external io_context (caller runs the loop).
- Socket readiness is detected via `asio::ip::tcp::socket::async_wait` driven by curl's `CURLMOPT_SOCKETFUNCTION`/`CURLMOPT_TIMERFUNCTION` — no polling, sub-millisecond latency.
- Completion callbacks are dispatched off the strand onto the io_context so slow callbacks don't starve the curl event loop. Exceptions in callbacks are caught and logged.
## Files
| File | Change |
|------|--------|
| `zenhttp/include/zenhttp/asynchttpclient.h` | New public header |
| `zenhttp/clients/asynchttpclient.cpp` | Implementation (~1000 lines) |
| `zenhttp/clients/httpclientcurlhelpers.h` | Shared curl helpers extracted from sync client |
| `zenhttp/clients/httpclientcurl.cpp` | Removed duplicated helpers, uses shared header |
| `zenhttp/asynchttpclient_test.cpp` | 8 test cases: verbs, payloads, callbacks, concurrency, external io_context, connection errors |
| `zenhttp/zenhttp.cpp` | Forcelink registration for new tests |
Diffstat (limited to 'docs/dev/VersioningCompatibility.md')
0 files changed, 0 insertions, 0 deletions