tgbot-cpp
Loading...
Searching...
No Matches
TgBot::CurlHttpClient Class Reference

This class makes http requests via libcurl. More...

#include <CurlHttpClient.h>

Inheritance diagram for TgBot::CurlHttpClient:
TgBot::HttpClient

Public Member Functions

 CurlHttpClient ()
 
 ~CurlHttpClient () override
 
std::string makeRequest (const Url &url, const std::vector< HttpReqArg > &args) const override
 Sends a request to the url.
 
- 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.
 

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
 

Detailed Description

This class makes http requests via libcurl.

Definition at line 26 of file CurlHttpClient.h.

Constructor & Destructor Documentation

◆ CurlHttpClient()

TgBot::CurlHttpClient::CurlHttpClient ( )

◆ ~CurlHttpClient()

TgBot::CurlHttpClient::~CurlHttpClient ( )
override

Member Function Documentation

◆ makeRequest()

std::string TgBot::CurlHttpClient::makeRequest ( const Url & url,
const std::vector< HttpReqArg > & args ) const
overridevirtual

Sends a request to the url.

If there's no args specified, a GET request will be sent, otherwise a POST request will be sent. If at least 1 arg is marked as file, the content type of a request will be multipart/form-data, otherwise it will be application/x-www-form-urlencoded.

Implements TgBot::HttpClient.

Member Data Documentation

◆ curlHandles

std::unordered_map<std::thread::id, CURL*> TgBot::CurlHttpClient::curlHandles

Raw curl handles, each thread has its own handle.

Definition at line 43 of file CurlHttpClient.h.

◆ curlHandlesMutex

std::mutex TgBot::CurlHttpClient::curlHandlesMutex

Lock for curlHandles access.

Definition at line 48 of file CurlHttpClient.h.


The documentation for this class was generated from the following file: