10 #ifndef __PION_HTTP_RESPONSE_HEADER__ 11 #define __PION_HTTP_RESPONSE_HEADER__ 13 #include <boost/shared_ptr.hpp> 14 #include <boost/lexical_cast.hpp> 15 #include <pion/config.hpp> 16 #include <pion/http/message.hpp> 17 #include <pion/http/request.hpp> 38 : m_status_code(RESPONSE_CODE_OK),
39 m_status_message(RESPONSE_MESSAGE_OK)
50 : m_status_code(RESPONSE_CODE_OK), m_status_message(RESPONSE_MESSAGE_OK),
51 m_request_method(request_method)
57 m_status_code(http_response.m_status_code),
58 m_status_message(http_response.m_status_message),
59 m_request_method(http_response.m_request_method)
65 : m_status_code(RESPONSE_CODE_OK),
66 m_status_message(RESPONSE_MESSAGE_OK)
75 m_status_code = RESPONSE_CODE_OK;
76 m_status_message = RESPONSE_MESSAGE_OK;
77 m_request_method.clear();
82 return (m_request_method == REQUEST_METHOD_HEAD
83 || (m_status_code >= 100 && m_status_code <= 199)
84 || m_status_code == 204 || m_status_code == 205
85 || m_status_code == 304
116 m_status_message = msg;
134 inline void set_cookie(
const std::string& name,
const std::string& value) {
136 add_header(HEADER_SET_COOKIE, set_cookie_header);
147 inline void set_cookie(
const std::string& name,
const std::string& value,
148 const std::string& path)
151 add_header(HEADER_SET_COOKIE, set_cookie_header);
162 inline void set_cookie(
const std::string& name,
const std::string& value,
163 const std::string& path,
const unsigned long max_age)
166 add_header(HEADER_SET_COOKIE, set_cookie_header);
176 inline void set_cookie(
const std::string& name,
const std::string& value,
177 const unsigned long max_age)
180 add_header(HEADER_SET_COOKIE, set_cookie_header);
186 add_header(HEADER_SET_COOKIE, set_cookie_header);
190 inline void delete_cookie(
const std::string& name,
const std::string& path) {
192 add_header(HEADER_SET_COOKIE, set_cookie_header);
209 m_first_line += boost::lexical_cast<std::string>(m_status_code);
212 m_first_line += m_status_message;
226 unsigned int m_status_code;
229 std::string m_status_message;
232 std::string m_request_method;
237 typedef boost::shared_ptr<response> response_ptr;
void set_cookie(const std::string &name, const std::string &value, const std::string &path)
void clear_first_line(void) const
virtual void clear(void)
clears all response data
void delete_cookie(const std::string &name, const std::string &path)
deletes cookie called name by adding a Set-Cookie header (cookie has a path)
void set_cookie(const std::string &name, const std::string &value, const std::string &path, const unsigned long max_age)
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
void set_status_code(unsigned int n)
sets the HTTP response status code
void set_version_minor(const boost::uint16_t n)
sets the minor HTTP version number
void set_version_major(const boost::uint16_t n)
sets the major HTTP version number
void change_header(const std::string &key, const std::string &value)
changes the value for the HTTP header named key
void set_chunks_supported(bool b)
set to true if chunked transfer encodings are supported
boost::uint16_t get_version_minor(void) const
returns the minor HTTP version number
static std::string get_date_string(const time_t t)
converts time_t format into an HTTP-date string
unsigned int get_status_code(void) const
returns the HTTP response status code
std::string get_version_string(void) const
returns a string representation of the HTTP version (i.e. "HTTP/1.1")
virtual ~response()
virtual destructor
virtual bool is_content_length_implied(void) const
the content length may be implied for certain types of responses
void delete_cookie(const std::string &name)
deletes cookie called name by adding a Set-Cookie header (cookie has no path)
response(const std::string &request_method)
void set_status_message(const std::string &msg)
sets the HTTP response status message
response(const http::request &http_request_ptr)
const std::string & get_status_message(void) const
returns the HTTP response status message
const std::string & get_method(void) const
returns the request method (i.e. GET, POST, PUT)
void set_cookie(const std::string &name, const std::string &value, const unsigned long max_age)
virtual void append_cookie_headers(void)
appends HTTP headers for any cookies defined by the http::message
response(const response &http_response)
copy constructor
boost::uint16_t get_version_major(void) const
returns the major HTTP version number
void update_request_info(const http::request &http_request)
virtual void update_first_line(void) const
updates the string containing the first line for the HTTP message
ihash_multimap & get_cookies(void)
returns the cookie parameters
static std::string make_set_cookie_header(const std::string &name, const std::string &value, const std::string &path, const bool has_max_age=false, const unsigned long max_age=0)
void set_last_modified(const unsigned long t)
sets the time that the response was last modified (Last-Modified)
void set_cookie(const std::string &name, const std::string &value)