]> git.mxchange.org Git - flightgear.git/blob - src/Network/HTTPClient.cxx
Bug 974, GPS exceptions at end-of-route.
[flightgear.git] / src / Network / HTTPClient.cxx
1 // HTTPClient.cxx -- Singleton HTTP client object
2 //
3 // Written by James Turner, started April 2012.
4 //
5 // Copyright (C) 2012  James Turner
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20
21 #include "HTTPClient.hxx"
22
23 #include <Main/fg_props.hxx>
24 #include <simgear/sg_inlines.h>
25
26 FGHTTPClient::FGHTTPClient()
27 {
28 }
29
30 FGHTTPClient::~FGHTTPClient()
31 {
32 }
33
34 void FGHTTPClient::init()
35 {
36   _http.reset(new simgear::HTTP::Client);
37   
38   std::string proxyHost(fgGetString("/sim/presets/proxy/host"));
39   int proxyPort(fgGetInt("/sim/presets/proxy/port"));
40   std::string proxyAuth(fgGetString("/sim/presets/proxy/auth"));
41   
42   if (!proxyHost.empty()) {
43     _http->setProxy(proxyHost, proxyPort, proxyAuth);
44   }
45 }
46
47 void FGHTTPClient::shutdown()
48 {
49   _http.reset();
50 }
51
52 void FGHTTPClient::update(double dt)
53 {
54   SG_UNUSED(dt);
55   _http->update();
56 }
57
58 void FGHTTPClient::makeRequest(const simgear::HTTP::Request_ptr& req)
59 {
60   _http->makeRequest(req);
61 }