tgbot-cpp
Loading...
Searching...
No Matches
CurlHttpClient.h
Go to the documentation of this file.
1#ifndef TGBOT_CURLHTTPCLIENT_H
2#define TGBOT_CURLHTTPCLIENT_H
3
4#ifdef HAVE_CURL
5
7#include "tgbot/net/Url.h"
10
11#include <curl/curl.h>
12
13#include <mutex>
14#include <string>
15#include <vector>
16#include <thread>
17#include <unordered_map>
18
19namespace TgBot {
20
26class TGBOT_API CurlHttpClient : public HttpClient {
27
28public:
30 ~CurlHttpClient() override;
31
38 std::string makeRequest(const Url& url, const std::vector<HttpReqArg>& args) const override;
39
43 std::unordered_map<std::thread::id, CURL*> curlHandles;
44
48 std::mutex curlHandlesMutex;
49
50private:
51 const HttpParser _httpParser;
52};
53
54}
55
56#endif
57
58#endif //TGBOT_CURLHTTPCLIENT_H
This class makes http requests via libcurl.
std::unordered_map< std::thread::id, CURL * > curlHandles
Raw curl handles, each thread has its own handle.
std::mutex curlHandlesMutex
Lock for curlHandles access.
std::string makeRequest(const Url &url, const std::vector< HttpReqArg > &args) const override
Sends a request to the url.
~CurlHttpClient() override
This class makes http requests.
Definition HttpClient.h:18
This class parses a string with the url.
Definition Url.h:15
Definition Api.h:40