]> git.mxchange.org Git - flightgear.git/blobdiff - src/Network/HTTPClient.cxx
Fix for bug 1304 - crash loading XML route
[flightgear.git] / src / Network / HTTPClient.cxx
index ca293d83ccb4df26691419a3755d872ff11c7acb..b97c7e41c82ba9cd7cd4c1e4ba22f253b5e64bf0 100644 (file)
 #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);
 }