]> git.mxchange.org Git - simgear.git/blob - simgear/io/HTTPClient.hxx
Fix missing include for non-Mac
[simgear.git] / simgear / io / HTTPClient.hxx
1 /**
2  * \file HTTPClient.hxx - simple HTTP client engine for SimHear
3  */
4
5 // Written by James Turner
6 //
7 // Copyright (C) 2013  James Turner  <zakalawe@mac.com>
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Library General Public
11 // License as published by the Free Software Foundation; either
12 // version 2 of the License, or (at your option) any later version.
13 //
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 // Library General Public License for more details.
18 //
19 // You should have received a copy of the GNU General Public License
20 // along with this program; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
22 //
23
24 #ifndef SG_HTTP_CLIENT_HXX
25 #define SG_HTTP_CLIENT_HXX
26
27 #include <memory> // for std::auto_ptr
28
29 #include <simgear/io/HTTPRequest.hxx>
30
31 namespace simgear
32 {
33
34 namespace HTTP
35 {
36
37 // forward decls
38 class Connection;
39     
40 class Client
41 {
42 public:
43     Client();
44     ~Client();
45     
46     void update(int waitTimeout = 0);
47     
48     void makeRequest(const Request_ptr& r);
49     
50     void setUserAgent(const std::string& ua);
51     void setProxy(const std::string& proxy, int port, const std::string& auth = "");
52     
53     /**
54      * Specify the maximum permitted simultaneous connections
55      * (default value is 1)
56      */
57     void setMaxConnections(unsigned int maxCons);
58     
59     const std::string& userAgent() const;
60         
61     const std::string& proxyHost() const;
62         
63     const std::string& proxyAuth() const;
64     
65     /**
66      * predicate, check if at least one connection is active, with at
67      * least one request active or queued.
68      */
69     bool hasActiveRequests() const; 
70 private:
71     void requestFinished(Connection* con);
72     
73     friend class Connection;
74     friend class Request;
75     
76     class ClientPrivate;
77     std::auto_ptr<ClientPrivate> d;
78 };
79
80 } // of namespace HTTP
81
82 } // of namespace simgear
83
84 #endif // of SG_HTTP_CLIENT_HXX