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 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::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 18 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 51 of file HttpClient.h.

◆ getCancelExceptionText()

virtual const std::string & TgBot::HttpClient::getCancelExceptionText ( ) const
inlinevirtual

Get the exception message that occurs when the request is aborted.

Definition at line 69 of file HttpClient.h.

◆ getRequestBackoff()

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

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

Definition at line 41 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 34 of file HttpClient.h.

◆ isEternalCancelled()

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

Checks if the HTTP client is permanently disabled.

Definition at line 62 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 82 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 77 of file HttpClient.h.

◆ _timeout

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

Definition at line 29 of file HttpClient.h.


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