tgbot-cpp
Loading...
Searching...
No Matches
TgBot::HttpClient Class Referenceabstract

This class makes http requests. More...

#include <HttpClient.h>

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

Public Member Functions

virtual ~HttpClient ()=default
virtual std::string makeRequest (const std::string &url, std::span< const HttpFormField > fields) const =0
 Sends a request to the url.
virtual int getRequestMaxRetries () const
 Get the maximum number of makeRequest() retries before giving up and throwing an exception.
virtual int getRequestBackoffSeconds () 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.

Public Attributes

std::int32_t _timeout = 25

Protected Attributes

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.

Detailed Description

This class makes http requests.

Definition at line 31 of file HttpClient.h.

Constructor & Destructor Documentation

◆ ~HttpClient()

virtual TgBot::HttpClient::~HttpClient ( )
virtualdefault

Member Function Documentation

◆ cancel()

virtual void TgBot::HttpClient::cancel ( const bool eternal = false) const
inlinevirtual

Cancels the requests.

Parameters
eternalOptional. If true, permanently disables the HTTP client, canceling all current and future requests. If false, cancel the currently running requests.

Definition at line 64 of file HttpClient.h.

◆ getRequestBackoffSeconds()

virtual int TgBot::HttpClient::getRequestBackoffSeconds ( ) const
inlinevirtual

Get the makeRequest() backoff duration between retries, in seconds.

Definition at line 54 of file HttpClient.h.

◆ getRequestMaxRetries()

virtual int TgBot::HttpClient::getRequestMaxRetries ( ) const
inlinevirtual

Get the maximum number of makeRequest() retries before giving up and throwing an exception.

Definition at line 47 of file HttpClient.h.

◆ isEternalCancelled()

virtual bool TgBot::HttpClient::isEternalCancelled ( ) const
inlinevirtual

Checks if the HTTP client is permanently disabled.

Definition at line 75 of file HttpClient.h.

◆ makeRequest()

virtual std::string TgBot::HttpClient::makeRequest ( const std::string & url,
std::span< const HttpFormField > fields ) const
pure virtual

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.

Implemented in TgBot::CurlHttpClient.

Member Data Documentation

◆ _cancelEpoch

std::atomic<uint64_t> TgBot::HttpClient::_cancelEpoch { 0 }
mutableprotected

Counter used to invalidate current requests.

Definition at line 88 of file HttpClient.h.

◆ _isEternalCancel

std::atomic<bool> TgBot::HttpClient::_isEternalCancel { false }
mutableprotected

Flag indicating whether the HTTP client is permanently disabled.

Definition at line 83 of file HttpClient.h.

◆ _timeout

std::int32_t TgBot::HttpClient::_timeout = 25

Definition at line 42 of file HttpClient.h.


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