a mirror because nheko.im bans tor

Nicolas Werner f49993e6ad Upgrade spdlog wrap 5 bulan lalu
cmake ed4c355cbe Try to fix cmake fetch content 3 tahun lalu
docs cd2667230f Add documentation 3 tahun lalu
examples e741ced9b2 Add clang-format and timeout requests if keepalive fails 3 tahun lalu
include cb217077ba Actually link to response headers 1 tahun lalu
lib 831e2ee8e9 Fix build with fmt10 1 tahun lalu
scripts f269f7feef Add tls tests, license, readme 3 tahun lalu
subprojects f49993e6ad Upgrade spdlog wrap 5 bulan lalu
tests 3b64edc558 Make tests use FetchContent 1 tahun lalu
.clang-format e741ced9b2 Add clang-format and timeout requests if keepalive fails 3 tahun lalu
.clang-format-include e741ced9b2 Add clang-format and timeout requests if keepalive fails 3 tahun lalu
.gitignore cd2667230f Add documentation 3 tahun lalu
.gitlab-ci.yml f1d6c4d52c Get rid of reuse in CI, which was never used 5 bulan lalu
.markdownlint.yaml 5393e25db2 Limit connections by default 2 tahun lalu
CHANGELOG.md 4bde892b72 Bump version 5 bulan lalu
CMakeLists.txt 612029517e Update hunter dependencies 5 bulan lalu
Doxyfile cd2667230f Add documentation 3 tahun lalu
Doxyfile-mcss cd2667230f Add documentation 3 tahun lalu
LICENSE f269f7feef Add tls tests, license, readme 3 tahun lalu
README.md dce3972226 Add badges 3 tahun lalu
clang-format edc73f2c2f Very basic lib based on curl libevent example 3 tahun lalu
meson.build 4bde892b72 Bump version 5 bulan lalu
meson_options.txt f269f7feef Add tls tests, license, readme 3 tahun lalu
toolchain.cmake 556b6b7b44 Add basic cmake support 3 tahun lalu

README.md

coeurl

Pipeline Status Coverage Documentation

Simple library to do http requests asynchronously via CURL in C++. (Eventually as coroutines, once all the compilers I need to support support them.)

This is based on the CURL-libevent example.

You can do a get request with 3 simple steps:

  1. Initialize the library: cpp coeurl::Client g{};
  2. Do a request cpp g.get("http://localhost:5000/", [](const coeurl::Request &res) { std::cout << res.response() << std::endl; });

If you need more flexibility, you can initialize a coeurl::Request manually and set all the fields required. Currently only a few methods are exposed, but we may decide to add more in the future or expose the easy handle for direct manipulation.

Dependencies

  • CURL (duh!)
  • libevent
  • spdlog
  • for tests: doctest

Building

Usually meson should do all you need. For example you can build it like this in a subdirectory called buildir/:

meson setup builddir
meson compile -C builddir

There is also a cmake file, but this does not properly support installation. It is only useful for using this project via ExternalProject.

Limitations

The event loop can only run on one thread at a time! If you need to parallelize your request, use multiple clients or dispatch the responses into a threadpool manually. In most cases the one thread should be enough for the simpler workloads though and this way you can benefit from connection pooling and the HTTP/2 multiplexing. The tread is created internally and you currently have no control over it. You can wait for it to exit using close() or the ~Client destructor. If you block this thread, no other requests will get processed.

This library also only exposes the simple way to do things currently. This is all I need at the moment.

Interesting bits

  • You can enable logging or customize the logging by setting a logger with coeurl::Client::set_logger. Do this before you initialize any client!
  • The Request can be constructed builder style, then submitted and then you can query the Request once it has completed for the headers, status code, etc.
  • Don't modify the Request while it is in flight or call any members on it until it is completed, after you submitted it.