|
tgbot-cpp
|
This class makes http requests via libcurl. More...
#include <CurlHttpClient.h>
Public Member Functions | |
| CurlHttpClient () | |
| ~CurlHttpClient () override | |
| std::string | makeRequest (const std::string &url, std::span< const HttpFormField > fields) const override |
| Sends a request to the url. | |
| void | setProxy (const char *url=NULL, long timeout=20L) |
| Proxy URL (NULL = no proxy). | |
| Public Member Functions inherited from TgBot::HttpClient | |
| virtual | ~HttpClient ()=default |
| virtual int | getRequestMaxRetries () const |
| Get the maximum number of makeRequest() retries before giving up and throwing an exception. | |
| virtual int | getRequestBackoff () const |
| Get the makeRequest() backoff duration between retries, in seconds. | |
| virtual void | cancel (const bool eternal=false) const |
| Cancels the requests. | |
| virtual bool | isEternalCancelled () const |
| Checks if the HTTP client is permanently disabled. | |
| virtual const std::string & | getCancelExceptionText () const |
| Get the exception message that occurs when the request is aborted. | |
Public Attributes | |
| std::unordered_map< std::thread::id, CURL * > | curlHandles |
| Raw curl handles, each thread has its own handle. | |
| std::mutex | curlHandlesMutex |
| Lock for curlHandles access. | |
| Public Attributes inherited from TgBot::HttpClient | |
| std::int32_t | _timeout = 25 |
Additional Inherited Members | |
| Protected Attributes inherited from TgBot::HttpClient | |
| std::atomic< bool > | _isEternalCancel { false } |
| Flag indicating whether the HTTP client is permanently disabled. | |
| std::atomic< uint64_t > | _cancelEpoch { 0 } |
| Counter used to invalidate current requests. | |
This class makes http requests via libcurl.
Definition at line 21 of file CurlHttpClient.h.
| TgBot::CurlHttpClient::CurlHttpClient | ( | ) |
|
override |
|
overridevirtual |
Sends a request to the url.
If there are no fields, a GET request is sent. Otherwise, a multipart/form-data POST request is sent.
Implements TgBot::HttpClient.
|
inline |
Proxy URL (NULL = no proxy).
Definition at line 46 of file CurlHttpClient.h.
| std::unordered_map<std::thread::id, CURL*> TgBot::CurlHttpClient::curlHandles |
Raw curl handles, each thread has its own handle.
Definition at line 36 of file CurlHttpClient.h.
| std::mutex TgBot::CurlHttpClient::curlHandlesMutex |
Lock for curlHandles access.
Definition at line 41 of file CurlHttpClient.h.