UniSet  2.24.2
UHttpClient.h
1 #ifndef DISABLE_REST_API
2 /*
3  * Copyright (c) 2020 Pavel Vainerman.
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Lesser General Public License as
7  * published by the Free Software Foundation, version 2.1.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Lesser Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 // -------------------------------------------------------------------------
18 #ifndef UHttpClient_H_
19 #define UHttpClient_H_
20 // -------------------------------------------------------------------------
21 #include <string>
22 #include <Poco/Net/HTTPClientSession.h>
23 #include "DebugStream.h"
24 #include "PassiveTimer.h"
25 // -------------------------------------------------------------------------
26 namespace uniset
27 {
28  namespace UHttp
29  {
32  {
33  public:
34 
35  UHttpClient();
36  virtual ~UHttpClient();
37 
38  // request example: http://site.com/query?params
39  // \return "" if fail
40  std::string get( const std::string& host, int port, const std::string& request );
41 
42  void setTimeout( uniset::timeout_t usec );
43 
44  // in microseconds
45  uniset::timeout_t getTimeout();
46 
47  protected:
48  Poco::Net::HTTPClientSession session;
49 
50  private:
51  };
52  }
53 }
54 // -------------------------------------------------------------------------
55 #endif // UHttpClient_H_
56 // -------------------------------------------------------------------------
57 #endif
Definition: UHttpClient.h:32
Definition: CommonEventLoop.h:15