curl-cpp
static c++17 wrapper for curl with -fno-exceptions support
|
Classes | |
class | Exception |
Public Types | |
using | perform_ret_t = Ret_except< int, std::bad_alloc, Exception, Recursive_api_call_Exception, libcurl_bug > |
using | socket_callback_t = int(*)(CURL *curl_easy, curl_socket_t s, int what, void *userp, void *per_socketp) |
using | timer_callback_t = int(*)(CURLM *multi, long timeout_ms, void *userp) |
Public Member Functions | |
Multi_t ()=default | |
Multi_t (void *multi) noexcept | |
Multi_t (const Multi_t &)=delete | |
Multi_t (Multi_t &&) noexcept | |
Multi_t & | operator= (const Multi_t &)=delete |
Multi_t & | operator= (Multi_t &&) noexcept |
operator bool () const noexcept | |
bool | add_easy (Easy_ref_t &easy) noexcept |
void | remove_easy (Easy_ref_t &easy) noexcept |
std::size_t | get_number_of_handles () const noexcept |
void | set_multiplexing (long max_concurrent_stream) noexcept |
auto | poll (curl_waitfd *extra_fds=nullptr, unsigned extra_nfds=0U, int timeout=0) noexcept -> Ret_except< int, std::bad_alloc, libcurl_bug > |
auto | break_or_poll (curl_waitfd *extra_fds=nullptr, unsigned extra_nfds=0U, int timeout=0) noexcept -> Ret_except< int, std::bad_alloc, libcurl_bug > |
template<class perform_callback_t , class T > | |
auto | perform (perform_callback_t &&perform_callback, T &&arg) noexcept -> perform_ret_t |
void | register_callback (socket_callback_t socket_callback, void *socket_data, timer_callback_t timer_callback, void *timer_data) noexcept |
auto | multi_assign (curl_socket_t socketfd, void *per_sockptr) noexcept -> Ret_except< void, std::invalid_argument > |
template<class perform_callback_t , class T > | |
auto | multi_socket_action (curl_socket_t socketfd, int ev_bitmask, perform_callback_t &&perform_callback, T &&arg) noexcept -> perform_ret_t |
~Multi_t () | |
Protected Member Functions | |
auto | get_finished_easy () const noexcept -> std::pair< Easy_ref_t, Easy_ref_t::perform_ret_t > |
template<class perform_callback_t , class T > | |
void | callback_on_finished_easy (perform_callback_t &&perform_callback, T &&arg) |
auto | perform_impl () noexcept -> perform_ret_t |
auto | multi_socket_action_impl (curl_socket_t socketfd, int ev_bitmask) noexcept -> perform_ret_t |
auto | check_perform (long code, int running_handles_tmp, const char *fname) noexcept -> Ret_except< int, std::bad_alloc, Exception, Recursive_api_call_Exception, libcurl_bug > |
Protected Attributes | |
void * | curl_multi = nullptr |
std::size_t | handles = 0 |
Definition at line 29 of file curl_multi.hpp.
using curl::Multi_t::socket_callback_t = int (*)(CURL *curl_easy, curl_socket_t s, int what, void *userp, void *per_socketp) |
Interface for using arbitary event-based interface - multi_socket interface
Precondition for using this interface:
Definition at line 213 of file curl_multi.hpp.
using curl::Multi_t::timer_callback_t = int (*)(CURLM *multi, long timeout_ms, void *userp) |
timeout_ms | -1 means you should delete the timer. All other values are valid expire times in number of milliseconds. |
Your callback function timer_callback should install a non-repeating timer with an interval of timeout_ms.
When time that timer fires, call multi_socket_action().
The timer_callback will only be called when the timeout expire time is changed.
Definition at line 226 of file curl_multi.hpp.
|
default |
Construct an empty Multi_t that can only be move assigned with value or be destroyed.
|
noexcept |
This constructor takes CURLM*
multi | pass nullptr for an empty Multi_t that can only be move assigned with value or be destroyed. |
Definition at line 15 of file curl_multi.cc.
|
noexcept |
other | after mv operation, other is in unusable state and can only be destroyed or move assign another value. |
Definition at line 19 of file curl_multi.cc.
curl::Multi_t::~Multi_t | ( | ) |
Definition at line 43 of file curl_multi.cc.
|
protectednoexcept |
Definition at line 102 of file curl_multi.cc.
other | after mv operation, other is in unusable state and can only be destroyed or move assign another value. |
Definition at line 26 of file curl_multi.cc.
|
noexcept |
Definition at line 38 of file curl_multi.cc.
|
noexcept |
easy | must be in valid state |
Definition at line 49 of file curl_multi.cc.
|
noexcept |
Undefined behavior if easy is not valid or not added to this multi.
Definition at line 57 of file curl_multi.cc.
|
noexcept |
HTTP2 multiplexing configuration.
max_concurrent_stream | max concurrent stream for a given connection. Should be between [0, 2 ^ 31 - 1]. Set it to 0 disable multiplexing. |
Since curl_t::version >= 7.62.0 (version released way after http2 multiplex support) , multiplex is turned on by default.
NOTE that libcurl not always accept max_concurrent_stream tuning.
Check curl_t::has_max_concurrent_stream_support().
If libcurl does not support tuning, this option will be only used for turning on and off the http2 multiplex.
Definition at line 68 of file curl_multi.cc.
|
noexcept |
timeout | Must be >= 0, in ms. Pass 0 for infinite. |
poll can return if interesting events has happened or timeout ms has passed and nothing has heppend.
It also can return due to pending internal timeout that has a shorter expiry time than timeout_ms.
Definition at line 78 of file curl_multi.cc.
|
noexcept |
timeout | Must be >= 0, in ms. Pass 0 for infinite. |
Behavior is same as poll.
Definition at line 93 of file curl_multi.cc.
|
inlinenoexcept |
arg | will be passed to perform_callback |
perform_callback | Must be callable with (Easy_ref_t, Easy_ref_t::perform_ret_t, Multi_t&, T) If you want to destroy and free easy.curl_easy, you must first multi.remove_easy(easy_ref) it. If easy_ref isn't removed from Multi, then the same transfer will happen again in the next call to Multi_t::perform. |
perform() is called only if poll is used.
After perform, perform_callback will be called for each completed easy.
YOU MUST CALL perform() after to start the transfer, then poll
Using libcurl version >= 7.10.3 can provide better error message if Easy_ref_t::ProtocolInternal_error is thrown.
Definition at line 187 of file curl_multi.hpp.
|
noexcept |
socket_callback,timer_callback | setting them to nullptr would disable multi_socket_action interface. |
You must call this function with non-NULL socket_callback and timer_callback before adding any easy handles.
Definition at line 138 of file curl_multi.cc.
|
noexcept |
By default, per_sockptr == nullptr.
You can call this function from socket_callback.
Definition at line 148 of file curl_multi.cc.
|
inlinenoexcept |
perform_callback | Must be callable with (Easy_ref_t, Easy_ref_t::perform_ret_t, Multi_t&, T) If you want to destroy and free easy.curl_easy, you must first multi.remove_easy(easy_ref) it. If easy_ref isn't removed from Multi, then the same transfer will happen again in the next call to Multi_t::multi_socket_action(socketfd of this easy handler, events, ...). |
socketfd | fd to be notified; CURL_SOCKET_TIMEOUT on timeout or to initiate the whole process. |
ev_bitmask | Or-ed with 0 or one of the value below:
|
YOU MUST CALL multi_socket_action(CURL_SOCKET_TIMEOUT, 0) to start the transfer, then call waitever poll interface you use
After multi_socket_action, perform_callback will be called for each completed easy.
Using libcurl version >= 7.10.3 can provide better error message if Easy_ref_t::ProtocolInternal_error is thrown.
Definition at line 277 of file curl_multi.hpp.