10 #ifndef __PION_HTTP_REQUEST_HEADER__ 11 #define __PION_HTTP_REQUEST_HEADER__ 13 #include <boost/shared_ptr.hpp> 14 #include <pion/config.hpp> 15 #include <pion/http/message.hpp> 16 #include <pion/user.hpp> 37 : m_method(REQUEST_METHOD_GET), m_resource(resource) {}
40 request(
void) : m_method(REQUEST_METHOD_GET) {}
50 m_original_resource.erase();
51 m_query_string.erase();
52 m_query_params.clear();
53 m_user_record.reset();
60 inline const std::string&
get_method(
void)
const {
return m_method; }
63 inline const std::string&
get_resource(
void)
const {
return m_resource; }
72 inline const std::string&
get_query(
const std::string& key)
const {
78 return m_query_params;
82 inline bool has_query(
const std::string& key)
const {
83 return(m_query_params.find(key) != m_query_params.end());
94 m_resource = m_original_resource = str;
103 m_query_string = str;
108 inline void add_query(
const std::string& key,
const std::string& value) {
109 m_query_params.insert(std::make_pair(key, value));
113 inline void change_query(
const std::string& key,
const std::string& value) {
132 if (! post_content.empty())
133 memcpy(ptr, post_content.c_str(), post_content.size());
143 memcpy(ptr, value.c_str(), value.size());
149 if ( NULL == value || 0 == size )
153 memcpy(ptr, value, size);
160 inline user_ptr
get_user()
const {
return m_user_record; }
172 if (! m_query_string.empty()) {
185 std::string cookie_header;
186 cookie_header = i->first;
187 cookie_header += COOKIE_NAME_VALUE_DELIMITER;
188 cookie_header += i->second;
197 std::string m_method;
200 std::string m_resource;
203 std::string m_original_resource;
206 std::string m_query_string;
209 ihash_multimap m_query_params;
212 user_ptr m_user_record;
217 typedef boost::shared_ptr<request> request_ptr;
void clear_first_line(void) const
bool has_query(const std::string &key) const
returns true if at least one value for the query key is defined
void delete_query(const std::string &key)
removes all values for a query key
virtual ~request()
virtual destructor
void set_content(const std::string &value)
add content (for POST) from string
const std::string & get_resource(void) const
returns the resource uri-stem to be delivered (possibly the result of a redirect) ...
void add_header(const std::string &key, const std::string &value)
adds a value for the HTTP header named key
virtual void clear(void)
clears all message data
virtual void clear(void)
clears all request data
void change_resource(const std::string &str)
changes the resource or uri-stem to be delivered (called as the result of a redirect) ...
user_ptr get_user() const
get the user record for HTTP request after authentication
static const std::string & get_value(const DictionaryType &dict, const std::string &key)
const std::string & get_original_resource(void) const
returns the resource uri-stem originally requested
void set_content_length(size_t n)
sets the length of the payload content (in bytes)
void set_content_type(const std::string &type)
sets the content type for the message payload
static void change_value(DictionaryType &dict, const std::string &key, const std::string &value)
request(void)
constructs a new request object (default constructor)
void set_method(const std::string &str)
sets the HTTP request method (i.e. GET, POST, PUT)
std::string get_version_string(void) const
returns a string representation of the HTTP version (i.e. "HTTP/1.1")
void set_user(user_ptr user)
sets the user record for HTTP request after authentication
void set_content(const char *value, size_t size)
const std::string & get_query(const std::string &key) const
returns a value for the query key if any are defined; otherwise, an empty string
void change_query(const std::string &key, const std::string &value)
changes the value of a query key
void add_query(const std::string &key, const std::string &value)
adds a value for the query key
const std::string & get_method(void) const
returns the request method (i.e. GET, POST, PUT)
virtual void update_first_line(void) const
updates the string containing the first line for the HTTP message
virtual void append_cookie_headers(void)
appends HTTP headers for any cookies defined by the http::message
const std::string & get_query_string(void) const
returns the uri-query or query string requested
char * create_content_buffer(void)
static void delete_value(DictionaryType &dict, const std::string &key)
void use_query_params_for_query_string(void)
use the query parameters to build a query string for the request
void set_query_string(const std::string &str)
sets the uri-query or query string requested
virtual bool is_content_length_implied(void) const
the content length of the message can never be implied for requests
ihash_multimap & get_queries(void)
returns the query parameters
request(const std::string &resource)
ihash_multimap & get_cookies(void)
returns the cookie parameters
void use_query_params_for_post_content(void)
use the query parameters to build POST content for the request
static std::string make_query_string(const ihash_multimap &query_params)
builds an HTTP query string from a collection of query parameters
void set_resource(const std::string &str)
sets the resource or uri-stem originally requested