9 #ifndef INCLUDE_FUNAPI_NETWORK_HTTP_CLIENT_H_ 10 #define INCLUDE_FUNAPI_NETWORK_HTTP_CLIENT_H_ 12 #include <boost/enable_shared_from_this.hpp> 13 #include <boost/function.hpp> 26 :
public boost::enable_shared_from_this<HttpClient>,
27 private boost::noncopyable {
34 typedef function<void(const CURLcode, const http::Response &)>
Handler;
35 typedef function<void(
const CURLcode,
const string &error_desc,
48 void SetHeader(
const string &key,
const string &value);
52 void UnsetHeader(
const string &key);
60 CURLcode Get(
const string &url,
size_t timeout_in_ms = 0);
67 CURLcode Post(
const string &url,
const Ptr<const string> &data,
68 size_t timeout_in_ms = 0);
75 CURLcode Post(
const string &url,
const Json &data,
size_t timeout_in_ms = 0);
83 CURLcode Post(
const string &url,
const curl_httppost *data,
84 size_t timeout_in_ms = 0);
91 CURLcode Put(
const string &url,
const Ptr<const string> &data,
92 size_t timeout_in_ms = 0);
99 CURLcode Put(
const string &url,
const Json &data,
size_t timeout_in_ms = 0);
106 CURLcode Delete(
const string &url,
const Ptr<const string> &data,
107 size_t timeout_in_ms = 0);
114 CURLcode Delete(
const string &url,
const Json &data,
115 size_t timeout_in_ms = 0);
120 void GetAsync(
const string &url,
const Handler &handler,
121 size_t timeout_in_ms = 0);
127 void PostAsync(
const string &url,
const Ptr<const string> &data,
128 const Handler &handler,
size_t timeout_in_ms = 0);
135 void PostAsync(
const string &url,
const Json &data,
136 const Handler &handler,
size_t timeout_in_ms = 0);
144 void PostAsync(
const string &url,
const curl_httppost *data,
145 const Handler &handler,
size_t timeout_in_ms = 0);
151 void PutAsync(
const string &url,
const Ptr<const string> &data,
152 const Handler &handler,
size_t timeout_in_ms = 0);
159 void PutAsync(
const string &url,
const Json &data,
160 const Handler &handler,
size_t timeout_in_ms = 0);
166 void DeleteAsync(
const string &url,
const Ptr<const string> &data,
167 const Handler &handler,
size_t timeout_in_ms = 0);
174 void DeleteAsync(
const string &url,
const Json &data,
175 const Handler &handler,
size_t timeout_in_ms = 0);
180 void GetAsync2(
const string &url,
const Handler2 &handler,
181 size_t timeout_in_ms = 0);
187 void PostAsync2(
const string &url,
const Ptr<const string> &data,
188 const Handler2 &handler,
size_t timeout_in_ms = 0);
195 void PostAsync2(
const string &url,
const Json &data,
196 const Handler2 &handler,
size_t timeout_in_ms = 0);
204 void PostAsync2(
const string &url,
const curl_httppost *data,
205 const Handler2 &handler,
size_t timeout_in_ms = 0);
211 void PutAsync2(
const string &url,
const Ptr<const string> &data,
212 const Handler2 &handler,
size_t timeout_in_ms = 0);
219 void PutAsync2(
const string &url,
const Json &data,
220 const Handler2 &handler,
size_t timeout_in_ms = 0);
226 void DeleteAsync2(
const string &url,
const Ptr<const string> &data,
227 const Handler2 &handler,
size_t timeout_in_ms = 0);
234 void DeleteAsync2(
const string &url,
const Json &data,
235 const Handler2 &handler,
size_t timeout_in_ms = 0);
243 const string &error_message()
const;
253 void set_verbose(
bool on);
262 #endif // INCLUDE_FUNAPI_NETWORK_HTTP_CLIENT_H_
function< void(const CURLcode, const http::Response &)> Handler
Handler type for asynchronous operations.
Definition: http_client.h:34
Data structure to hold HTTP response.
Definition: http_util.h:137
Curl-based HTTP(s) client.
Definition: http_client.h:25
#define DECLARE_CLASS_PTR(CLS)
Utility macro to forward-declare smart pointer types for a given class.
Definition: types.h:89