22 #ifndef _LIBS_WEBVIEW_REQUEST_H_
23 #define _LIBS_WEBVIEW_REQUEST_H_
25 #include <arpa/inet.h>
26 #include <utils/time/time.h>
27 #include <webview/reply.h>
33 struct MHD_Connection;
34 struct MHD_PostProcessor;
39 class WebRequestDispatcher;
60 typedef enum { HTTP_VERSION_1_0, HTTP_VERSION_1_1 }
HttpVersion;
125 const std::map<std::string, std::string> &
135 cookie(std::string &key)
const
137 std::map<std::string, std::string>::const_iterator c = cookies_.find(key);
138 return (c != cookies_.end()) ? c->second :
"";
147 return (cookies_.find(key) != cookies_.end());
152 const std::map<std::string, std::string> &
164 std::map<std::string, std::string>::const_iterator p = post_values_.find(key);
165 return (p != post_values_.end()) ? p->second :
"";
174 std::map<std::string, std::string>::const_iterator p = post_values_.find(key);
175 return (p != post_values_.end()) ? p->second :
"";
184 return (post_values_.find(key) != post_values_.end());
189 const std::map<std::string, std::string> &
201 std::map<std::string, std::string>::const_iterator p = get_values_.find(key);
202 return (p != get_values_.end()) ? p->second :
"";
211 std::map<std::string, std::string>::const_iterator p = get_values_.find(key);
212 return (p != get_values_.end()) ? p->second :
"";
221 return (get_values_.find(key) != get_values_.end());
226 const std::map<std::string, std::string> &
236 header(std::string &key)
const
238 std::map<std::string, std::string>::const_iterator p = headers_.find(key);
239 return (p != headers_.end()) ? p->second :
"";
246 header(
const char *key)
const
248 std::map<std::string, std::string>::const_iterator p = headers_.find(key);
249 return (p != headers_.end()) ? p->second :
"";
258 return (headers_.find(key) != headers_.end());
266 set_cookie(
const std::string &key,
const std::string &value)
268 cookies_[key] = value;
271 void set_post_value(
const char *key,
const char *data,
size_t size);
278 set_get_value(
const std::string &key,
const std::string &value)
280 get_values_[key] = value;
288 set_header(
const std::string &key,
const std::string &value)
290 headers_[key] = value;
300 path_arg(
const std::string &what)
const
302 const auto p = path_args_.find(what);
303 if (p != path_args_.end()) {
316 path_args_ = std::move(args);
344 void set_body(
const char *data,
size_t data_size);
345 void addto_body(
const char *data,
size_t data_size);
354 void setup(
const char *
url,
const char *
method,
const char *version, MHD_Connection *connection);
357 MHD_PostProcessor *pp_;
363 std::string client_addr_;
369 std::map<std::string, std::string> cookies_;
370 std::map<std::string, std::string> post_values_;
372 std::map<std::string, std::string> get_values_;
373 std::map<std::string, std::string> headers_;
374 std::map<std::string, std::string> path_args_;