]> git.mxchange.org Git - simgear.git/blob - simgear/io/HTTPClient.hxx
Fix a crash where hostlookup fails entirely, thanks to Andreas Gaeb for the catch.
[simgear.git] / simgear / io / HTTPClient.hxx
1 #ifndef SG_HTTP_CLIENT_HXX
2 #define SG_HTTP_CLIENT_HXX
3
4 #include <map>
5
6 #include <simgear/io/HTTPRequest.hxx>
7
8 namespace simgear
9 {
10
11 namespace HTTP
12 {
13
14 class Connection;
15
16 class Client
17 {
18 public:
19     Client();
20     
21     void update();
22     
23     void makeRequest(const Request_ptr& r);
24     
25     void setUserAgent(const std::string& ua);
26     void setProxy(const std::string& proxy, int port, const std::string& auth = "");
27     
28     const std::string& userAgent() const
29         { return _userAgent; }
30         
31     const std::string& proxyHost() const
32         { return _proxy; }
33         
34     const std::string& proxyAuth() const
35         { return _proxyAuth; }
36 private:
37     void requestFinished(Connection* con);
38     
39     friend class Connection;
40     friend class Request;
41     
42     std::string _userAgent;
43     std::string _proxy;
44     int _proxyPort;
45     std::string _proxyAuth;
46     
47 // connections by host
48     typedef std::map<std::string, Connection*> ConnectionDict;
49     ConnectionDict _connections;
50 };
51
52 } // of namespace HTTP
53
54 } // of namespace simgear
55
56 #endif // of SG_HTTP_CLIENT_HXX