X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FNetwork%2FHTTPClient.cxx;h=b97c7e41c82ba9cd7cd4c1e4ba22f253b5e64bf0;hb=b0dcb657e77579ecc79798ff365737095f96f9e2;hp=ca293d83ccb4df26691419a3755d872ff11c7acb;hpb=2218a44ed76def7dcbe9233cfd34488ad66b7752;p=flightgear.git diff --git a/src/Network/HTTPClient.cxx b/src/Network/HTTPClient.cxx index ca293d83c..b97c7e41c 100644 --- a/src/Network/HTTPClient.cxx +++ b/src/Network/HTTPClient.cxx @@ -21,30 +21,40 @@ #include "HTTPClient.hxx" #include
+#include -static FGHTTPClient* static_instance = NULL; +FGHTTPClient::FGHTTPClient() +{ +} -FGHTTPClient* FGHTTPClient::instance() +FGHTTPClient::~FGHTTPClient() { - if (!static_instance) { - static_instance = new FGHTTPClient; - } - - return static_instance; } -bool FGHTTPClient::haveInstance() +void FGHTTPClient::init() { - return (static_instance != NULL); + _http.reset(new simgear::HTTP::Client); + + std::string proxyHost(fgGetString("/sim/presets/proxy/host")); + int proxyPort(fgGetInt("/sim/presets/proxy/port")); + std::string proxyAuth(fgGetString("/sim/presets/proxy/auth")); + + if (!proxyHost.empty()) { + _http->setProxy(proxyHost, proxyPort, proxyAuth); + } } -FGHTTPClient::FGHTTPClient() +void FGHTTPClient::shutdown() +{ + _http.reset(); +} + +void FGHTTPClient::update(double) +{ + _http->update(); +} + +void FGHTTPClient::makeRequest(const simgear::HTTP::Request_ptr& req) { - std::string proxyHost(fgGetString("/sim/presets/proxy/host")); - int proxyPort(fgGetInt("/sim/presets/proxy/port")); - std::string proxyAuth(fgGetString("/sim/presets/proxy/auth")); - - if (!proxyHost.empty()) { - setProxy(proxyHost, proxyPort, proxyAuth); - } + _http->makeRequest(req); }