a mirror because nheko.im bans tor
Nicolas Werner f49993e6ad Upgrade spdlog wrap | 5 months ago | |
---|---|---|
cmake | 3 years ago | |
docs | 3 years ago | |
examples | 3 years ago | |
include | 1 year ago | |
lib | 1 year ago | |
scripts | 3 years ago | |
subprojects | 5 months ago | |
tests | 1 year ago | |
.clang-format | 3 years ago | |
.clang-format-include | 3 years ago | |
.gitignore | 3 years ago | |
.gitlab-ci.yml | 5 months ago | |
.markdownlint.yaml | 2 years ago | |
CHANGELOG.md | 5 months ago | |
CMakeLists.txt | 5 months ago | |
Doxyfile | 3 years ago | |
Doxyfile-mcss | 3 years ago | |
LICENSE | 3 years ago | |
README.md | 3 years ago | |
clang-format | 3 years ago | |
meson.build | 5 months ago | |
meson_options.txt | 3 years ago | |
toolchain.cmake | 3 years ago |
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:
cpp
coeurl::Client g{};
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.
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.
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.
coeurl::Client::set_logger
. Do this before you initialize any client!