iFun Engine API  1.0.0-b6053
Great Technology for Great Games
http_client_pool.h
Go to the documentation of this file.
1 // Copyright (C) 2013-2020 iFunFactory Inc. All Rights Reserved.
2 //
3 // This work is confidential and proprietary to iFunFactory Inc. and
4 // must not be used, disclosed, copied, or distributed without the prior
5 // consent of iFunFactory Inc.
6 
9 #ifndef INCLUDE_FUNAPI_NETWORK_HTTP_CLIENT_POOL_H_
10 #define INCLUDE_FUNAPI_NETWORK_HTTP_CLIENT_POOL_H_
11 
12 
14 #include <funapi/types.h>
15 
16 
17 #include <vector>
18 
19 
20 namespace fun {
21 
22 class FUNAPI_DLL_VISIBILITY HttpClientPool {
23  public:
24  typedef HttpClient::Handler Handler;
25  typedef std::map<string /*key*/, string /*value*/> HeaderMap;
26 
27  static const HeaderMap kNullHeader;
28 
29  static void GetAsync(const string &url, const Handler &handler,
30  size_t timeout_in_ms = 0);
31  static void GetAsync(const string &url, const HeaderMap &headers,
32  const Handler &handler, size_t timeout_in_ms = 0);
33 
34  static void PostAsync(const string &url, const Ptr<const string> &data,
35  const Handler &handler, size_t timeout_in_ms = 0);
36  static void PostAsync(const string &url, const Json &data,
37  const Handler &handler, size_t timeout_in_ms = 0);
38  static void PostAsync(const string &url, const curl_httppost *data,
39  const Handler &handler, size_t timeout_in_ms = 0);
40  static void PostAsync(const string &url, const HeaderMap &headers,
41  const Ptr<const string> &data,
42  const Handler &handler, size_t timeout_in_ms = 0);
43  static void PostAsync(const string &url, const HeaderMap &headers,
44  const Json &data, const Handler &handler,
45  size_t timeout_in_ms = 0);
46  static void PostAsync(const string &url, const HeaderMap &headers,
47  const curl_httppost *data, const Handler &handler,
48  size_t timeout_in_ms = 0);
49 
50  static void PutAsync(const string &url, const Ptr<const string> &data,
51  const Handler &handler, size_t timeout_in_ms = 0);
52  static void PutAsync(const string &url, const Json &data,
53  const Handler &handler, size_t timeout_in_ms = 0);
54  static void PutAsync(const string &url, const HeaderMap &headers,
55  const Ptr<const string> &data,
56  const Handler &handler, size_t timeout_in_ms = 0);
57  static void PutAsync(const string &url, const HeaderMap &headers,
58  const Json &data, const Handler &handler,
59  size_t timeout_in_ms = 0);
60 
61  static void DeleteAsync(const string &url, const Ptr<const string> &data,
62  const Handler &handler, size_t timeout_in_ms = 0);
63  static void DeleteAsync(const string &url, const Json &data,
64  const Handler &handler, size_t timeout_in_ms = 0);
65  static void DeleteAsync(const string &url, const HeaderMap &headers,
66  const Ptr<const string> &data, const Handler &handler,
67  size_t timeout_in_ms = 0);
68  static void DeleteAsync(const string &url, const HeaderMap &headers,
69  const Json &data, const Handler &handler,
70  size_t timeout_in_ms = 0);
71 
72  static CURLcode Get(const string &url, http::Response *response);
73  static CURLcode Get(const string &url, const HeaderMap &headers,
74  http::Response *response);
75 
76  static CURLcode Post(const string &url, const Ptr<const string> &data,
77  http::Response *response);
78  static CURLcode Post(const string &url, const Json &data,
79  http::Response *response);
80  static CURLcode Post(const string &url, const curl_httppost *data,
81  http::Response *response);
82  static CURLcode Post(const string &url, const HeaderMap &headers,
83  const Ptr<const string> &data,
84  http::Response *response);
85  static CURLcode Post(const string &url, const HeaderMap &headers,
86  const Json &data, http::Response *response);
87  static CURLcode Post(const string &url, const HeaderMap &headers,
88  const curl_httppost *data, http::Response *response);
89 
90  static CURLcode Put(const string &url, const Ptr<const string> &data,
91  http::Response *response);
92  static CURLcode Put(const string &url, const Json &data,
93  http::Response *response);
94  static CURLcode Put(const string &url, const HeaderMap &headers,
95  const Ptr<const string> &data,
96  http::Response *response);
97  static CURLcode Put(const string &url, const HeaderMap &headers,
98  const Json &data, http::Response *response);
99 
100  static CURLcode Delete(const string &url, const Json &data,
101  http::Response *response);
102  static CURLcode Delete(const string &url, const Ptr<const string> &data,
103  http::Response *response);
104  static CURLcode Delete(const string &url, const HeaderMap &headers,
105  const Json &data, http::Response *response);
106  static CURLcode Delete(const string &url, const HeaderMap &headers,
107  const Ptr<const string> &data,
108  http::Response *response);
109 
110  static size_t GetSize(const string &host);
111 
112  static void GetSizeAll(
113  std::vector<std::pair<string/*host*/, size_t/*size*/> > *out);
114 };
115 
116 } // namespace fun
117 
118 
119 #endif // INCLUDE_FUNAPI_NETWORK_HTTP_CLIENT_POOL_H_
function< void(const CURLcode, const http::Response &)> Handler
Handler type for asynchronous operations.
Definition: http_client.h:34
Definition: json.h:18
Data structure to hold HTTP response.
Definition: http_util.h:137
Definition: json.h:27
Definition: http_client_pool.h:22