From 95f86f4ce18e65d45894d5a130c4bdaf8ecbaac5 Mon Sep 17 00:00:00 2001 From: Egor Pugin Date: Wed, 4 Jul 2018 19:11:03 +0300 Subject: Implement CurlHttpClient. --- src/Api.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/Api.cpp') diff --git a/src/Api.cpp b/src/Api.cpp index 3d8d3f6..3bb200b 100644 --- a/src/Api.cpp +++ b/src/Api.cpp @@ -31,7 +31,8 @@ using namespace boost::property_tree; namespace TgBot { -Api::Api(const string& token) : _token(token) { +Api::Api(const string& token, const HttpClient &httpClientDriver) + : _token(token), _httpClientDriver(httpClientDriver) { } User::Ptr Api::getMe() const { @@ -1198,7 +1199,7 @@ ptree Api::sendRequest(const string& method, const vector& args) con url += "/"; url += method; - string serverResponse = HttpClient::getInstance().makeRequest(url, args); + string serverResponse = _httpClientDriver.makeRequest(url, args); if (!serverResponse.compare(0, 6, "")) { throw TgException("tgbot-cpp library have got html page instead of json response. Maybe you entered wrong bot token."); } @@ -1221,7 +1222,7 @@ string Api::downloadFile(const string& filePath, const std::vector& url += "/"; url += filePath; - string serverResponse = HttpClient::getInstance().makeRequest(url, args); + string serverResponse = _httpClientDriver.makeRequest(url, args); return serverResponse; } -- cgit v1.2.3