Examples

July 12, 2026 ยท View on GitHub

One focused program per file, written for readability. They build with the default configure (COFETCH_BUILD_EXAMPLES=ON) and hit public echo endpoints, so they need network access to run.

exampleshows
example_hello.cppthe smallest program: one GET, one callback
example_fluent.cppbuilding a POST with the chainable setters
example_coroutine.cppdependent requests in linear code (C++20 co_await)
example_future.cppstd::future style: start, drive, get()
example_sync.cppwrapping the async client in a blocking SyncClient facade
example_concurrent.cpp20 requests in flight on one thread
example_errors.cpptransport errors vs HTTP error statuses
example_cancellation.cppa time budget per request with asio::cancel_after
example_redirects.cpp3xx as-is by default; follow_redirects() to chase them
example_http2.cpprequests multiplexed over one HTTP/2 connection; opting a request back to HTTP/1.1
example_tls.cpphttps out of the box; TLS knobs via the .curl() escape hatch
example_compression.cppgzip/brotli responses arrive already decoded
example_keepalive.cppconnection pooling: the second request skips the handshake
example_reactors.cpprun() vs busy-poll() vs a foreign epoll loop; io_uring build