22 #ifndef __LIBS_WEBVIEW_REQUEST_H_ 23 #define __LIBS_WEBVIEW_REQUEST_H_ 25 #include <webview/reply.h> 26 #include <utils/time/time.h> 30 #include <arpa/inet.h> 33 struct MHD_Connection;
34 struct MHD_PostProcessor;
69 const std::string &
url()
const {
return url_; }
73 const std::string &
uri()
const {
return uri_; }
77 Method
method()
const {
return method_; }
91 const std::string &
user()
const {
return user_; }
95 const std::string &
client_addr()
const {
return client_addr_; }
99 const std::map<std::string, std::string> &
cookies()
const {
return cookies_; }
104 std::string
cookie(std::string &key)
const 106 std::map<std::string, std::string>::const_iterator c = cookies_.find(key);
107 return (c != cookies_.end()) ? c->second :
"";
114 {
return (cookies_.find(key) != cookies_.end()); }
118 const std::map<std::string, std::string> &
post_values()
const {
return post_values_; }
125 std::map<std::string, std::string>::const_iterator p = post_values_.find(key);
126 return (p != post_values_.end()) ? p->second :
"";
134 std::map<std::string, std::string>::const_iterator p = post_values_.find(key);
135 return (p != post_values_.end()) ? p->second :
"";
142 {
return (post_values_.find(key) != post_values_.end()); }
146 const std::map<std::string, std::string> &
get_values()
const {
return get_values_; }
153 std::map<std::string, std::string>::const_iterator p = get_values_.find(key);
154 return (p != get_values_.end()) ? p->second :
"";
162 std::map<std::string, std::string>::const_iterator p = get_values_.find(key);
163 return (p != get_values_.end()) ? p->second :
"";
170 {
return (get_values_.find(key) != get_values_.end()); }
175 const std::map<std::string, std::string> &
headers()
const {
return headers_; }
180 std::string
header(std::string &key)
const 182 std::map<std::string, std::string>::const_iterator p = headers_.find(key);
183 return (p != headers_.end()) ? p->second :
"";
189 std::string
header(
const char *key)
const 191 std::map<std::string, std::string>::const_iterator p = headers_.find(key);
192 return (p != headers_.end()) ? p->second :
"";
199 {
return (headers_.find(key) != headers_.end()); }
205 void set_cookie(
const std::string &key,
const std::string &value) { cookies_[key] = value; }
212 void set_post_value(
const char *key,
const char *data,
size_t size);
218 void set_get_value(
const std::string &key,
const std::string &value) { get_values_[key] = value; }
224 void set_header(
const std::string &key,
const std::string &value)
225 { headers_[key] = value; }
245 bool is_setup() {
return is_setup_; }
246 void setup(
const char *
url,
const char *
method,
247 const char *version, MHD_Connection *connection);
250 MHD_PostProcessor *pp_;
256 std::string client_addr_;
258 HttpVersion http_version_;
262 std::map<std::string, std::string> cookies_;
263 std::map<std::string, std::string> post_values_;
264 std::string post_raw_data_;
265 std::map<std::string, std::string> get_values_;
266 std::map<std::string, std::string> headers_;
const std::map< std::string, std::string > & get_values() const
Get map of GET values.
void set_reply_code(WebReply::Code code)
Set HTTP code of the final reply.
void set_header(const std::string &key, const std::string &value)
Set a header value.
const std::string & raw_post_data() const
Get raw post data.
std::string header(std::string &key) const
Header specific header value.
const std::string & client_addr() const
Get client address as string.
Fawkes library namespace.
WebRequest(const char *uri)
Constructor.
const Time & time() const
Get request time.
void set_cookie(const std::string &key, const std::string &value)
Set a cookie.
bool has_post_value(std::string key) const
Check if the named post value has been received.
size_t reply_size() const
Get number of bytes actually sent out so far.
A class for handling time.
bool has_get_value(std::string key) const
Check if the named get value has been received.
const std::map< std::string, std::string > & cookies() const
Get map of cookies.
std::string post_value(std::string &key) const
Get specific POST value.
Method method() const
Get HTTP transfer method.
std::string cookie(std::string &key) const
Get specific cookie.
std::string post_value(const char *key) const
Get specific POST value.
const std::string & uri() const
Get URI.
void set_post_value(const char *key, const char *data, size_t size)
Set a POST value.
std::string header(const char *key) const
Get specific header value.
bool has_header(std::string key) const
Check if the named header value has been received.
std::string get_value(std::string &key) const
Get specific GET value.
WebReply::Code reply_code() const
Get HTTP code of reply.
const char * http_version_str() const
Get HTTP version as string.
Web request meta data carrier.
const char * method_str() const
Get method as string.
HttpVersion http_version() const
Get HTTP version.
void increment_reply_size(size_t increment_by)
Increment reply bytes counter.
const std::map< std::string, std::string > & headers() const
Get map of header values.
bool has_cookie(std::string key) const
Check if the named cookie has been received.
std::string get_value(const char *key) const
Get specific GET value.
void set_raw_post_data(const char *data, size_t data_size)
Set raw post data.
void set_get_value(const std::string &key, const std::string &value)
Set a GET value.
const std::string & url() const
Get URL.
Method
HTTP transfer methods.
const std::string & user() const
Get name of authenticated user (basic auth).
const std::map< std::string, std::string > & post_values() const
Get map of POST values.
void set_cookies(const std::map< std::string, std::string > &cookies)
Set cookie map.