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> &
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> &
238 std::map<std::string, std::string>::const_iterator p = headers_.find(key);
239 return (p != headers_.end()) ? p->second :
"";
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());
268 cookies_[key] = value;
271 void set_post_value(
const char *key,
const char *data,
size_t size);
280 get_values_[key] = value;
290 headers_[key] = value;
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_;
A class for handling time.
Web request meta data carrier.
std::string get_value(const char *key) const
Get specific GET value.
const std::map< std::string, std::string > & get_values() const
Get map of GET values.
const std::string & body() const
Get body of request.
HttpVersion http_version() const
Get HTTP version.
const std::map< std::string, std::string > & cookies() const
Get map of cookies.
const std::map< std::string, std::string > & headers() const
Get map of header values.
WebRequest(const char *uri)
Constructor.
const std::string & client_addr() const
Get client address as string.
const Time & time() const
Get request time.
std::string post_value(const char *key) const
Get specific POST value.
const char * http_version_str() const
Get HTTP version as string.
bool has_header(std::string key) const
Check if the named header value has been received.
void set_cookies(const std::map< std::string, std::string > &cookies)
Set cookie map.
void addto_body(const char *data, size_t data_size)
Add to request body.
const char * method_str() const
Get method as string.
void finish_body()
Finalize body handling.
bool has_post_value(std::string key) const
Check if the named post value has been received.
bool has_cookie(std::string key) const
Check if the named cookie has been received.
Method method() const
Get HTTP transfer method.
void set_post_value(const char *key, const char *data, size_t size)
Set a POST value.
std::string post_value(std::string &key) const
Get specific POST value.
std::string header(std::string &key) const
Header specific header value.
void set_reply_code(WebReply::Code code)
Set HTTP code of the final reply.
const std::map< std::string, std::string > & post_values() const
Get map of POST values.
Method
HTTP transfer methods.
const std::string & url() const
Get URL.
size_t reply_size() const
Get number of bytes actually sent out so far.
std::string get_value(std::string &key) const
Get specific GET value.
std::string path_arg(const std::string &what) const
Get a path argument.
void set_cookie(const std::string &key, const std::string &value)
Set a cookie.
std::string cookie(std::string &key) const
Get specific cookie.
void set_header(const std::string &key, const std::string &value)
Set a header value.
bool has_get_value(std::string key) const
Check if the named get value has been received.
void increment_reply_size(size_t increment_by)
Increment reply bytes counter.
std::string header(const char *key) const
Get specific header value.
void set_path_args(std::map< std::string, std::string > &&args)
Set path arguments.
WebReply::Code reply_code() const
Get HTTP code of reply.
const std::string & uri() const
Get URI.
void set_body(const char *data, size_t data_size)
Set request body.
const std::string & user() const
Get name of authenticated user (basic auth).
void set_get_value(const std::string &key, const std::string &value)
Set a GET value.
Fawkes library namespace.