tgbot-cpp
Loading...
Searching...
No Matches
HttpClient.h
Go to the documentation of this file.
1#ifndef TGBOT_HTTPCLIENT_H
2#define TGBOT_HTTPCLIENT_H
3
4#include "tgbot/net/Url.h"
6
7#include <string>
8#include <vector>
9#include <cstdint>
10
11namespace TgBot {
12
18class TGBOT_API HttpClient {
19
20public:
21 virtual ~HttpClient() = default;
22
29 virtual std::string makeRequest(const Url& url, const std::vector<HttpReqArg>& args) const = 0;
30
31 std::int32_t _timeout = 25;
32
36 virtual int getRequestMaxRetries() const {
37 return requestMaxRetries;
38 }
39
43 virtual int getRequestBackoff() const {
44 return requestBackoff;
45 }
46
47private:
48 int requestMaxRetries = 3;
49 int requestBackoff = 1;
50};
51
52}
53
54
55#endif //TGBOT_HTTPCLIENT_H
This class makes http requests.
Definition HttpClient.h:18
virtual ~HttpClient()=default
virtual std::string makeRequest(const Url &url, const std::vector< HttpReqArg > &args) const =0
Sends a request to the url.
virtual int getRequestBackoff() const
Get the makeRequest() backoff duration between retries, in seconds.
Definition HttpClient.h:43
virtual int getRequestMaxRetries() const
Get the maximum number of makeRequest() retries before giving up and throwing an exception.
Definition HttpClient.h:36
This class parses a string with the url.
Definition Url.h:15
Definition Api.h:39