#include "HTTPClient.hxx"
#include <Main/fg_props.hxx>
+#include <simgear/sg_inlines.h>
-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);
}