Generic HTTP response header. More...
#include <cgicc/HTTPResponseHeader.h>
Public Member Functions | |
Constructor and Destructor | |
HTTPResponseHeader (const std::string &http_version, int status_code, const std::string &reason_phrase) | |
Create a new HTTP response header. | |
virtual | ~HTTPResponseHeader () |
Delete this HTTPResponseHeader. | |
Additional Header Management | |
HTTPResponseHeader & | addHeader (const std::string &header) |
Add a general, response, or entity header to this one. | |
HTTPResponseHeader & | addHeader (const std::string &name, const std::string &value) |
Add a general, response, or entity header to this one. | |
const std::vector< std::string > & | getHeaders () const |
Get a list of all additional headers. | |
Cookie Management | |
HTTPResponseHeader & | setCookie (const HTTPCookie &cookie) |
Set a cookie to go out with this HTTPResponseHeader. | |
const std::vector< HTTPCookie > & | getCookies () const |
Get a list of all cookies associated with this header. | |
Accessor methods | |
Retrieve information on the header | |
const std::string & | getHTTPVersion () const |
Get the HTTP version. | |
int | getStatusCode () const |
Get the 3-digit status code. | |
std::string | getReasonPhrase () const |
Get the reason phrase associated with the stats code. | |
Mutator methods | |
Set information on the header | |
HTTPResponseHeader & | getHTTPVersion (const std::string &http_version) |
Set the HTTP version. | |
HTTPResponseHeader & | getStatusCode (int status_code) |
Get the 3-digit status code. | |
HTTPResponseHeader & | getReasonPhrase (const std::string &reason_phrase) |
Get the reason phrase associated with the stats code. | |
![]() | |
MStreamable () | |
Empty constructor. | |
virtual | ~MStreamable () |
Empty destructor. | |
virtual void | render (std::ostream &out) const =0 |
Write this object to a stream. | |
Inherited Methods | |
virtual void | render (std::ostream &out) const |
Write this object to a stream. | |
Generic HTTP response header.
This class represents an HTTP response header as defined in section 6 of RFC 2616 (see http://www.w3.org)
All HTTP/1.1 reponses consist of an initial status line containing the HTTP version, a 3-digit status code, and a human-readable reason phrase explaining the status code.
The first digit of the Status-Code defines the class of response. The last two digits do not have any categorization role. There are 5 values for the first digit:
Definition at line 73 of file HTTPResponseHeader.h.
cgicc::HTTPResponseHeader::HTTPResponseHeader | ( | const std::string & | http_version, |
int | status_code, | ||
const std::string & | reason_phrase | ||
) |
Create a new HTTP response header.
http_version | The HTTP version string, usually HTTP/1.1 |
status_code | The 3-digit HTTP status code |
reason_phrase | A short textual description of the status code |
|
virtual |
Delete this HTTPResponseHeader.
HTTPResponseHeader & cgicc::HTTPResponseHeader::addHeader | ( | const std::string & | header | ) |
Add a general, response, or entity header to this one.
header | The text of the header to add |
HTTPResponseHeader & cgicc::HTTPResponseHeader::addHeader | ( | const std::string & | name, |
const std::string & | value | ||
) |
Add a general, response, or entity header to this one.
name | The name of the header element to add |
value | The value of the header element |
|
inline |
Get a list of all cookies associated with this header.
Definition at line 147 of file HTTPResponseHeader.h.
|
inline |
Get a list of all additional headers.
Definition at line 128 of file HTTPResponseHeader.h.
|
inline |
Get the HTTP version.
The HTTP version is a string of the form HTTP/1.1
Definition at line 165 of file HTTPResponseHeader.h.
|
inline |
Set the HTTP version.
The HTTP version is a string of the form HTTP/1.1
http_version | The HTTP version string, usually HTTP/1.1 |
Definition at line 204 of file HTTPResponseHeader.h.
|
inline |
Get the reason phrase associated with the stats code.
The reason phrase is a human-readable interpretation of the status code
Definition at line 185 of file HTTPResponseHeader.h.
|
inline |
Get the reason phrase associated with the stats code.
The reason phrase is a human-readable interpretation of the status code
reason_phrase | A short textual description of the status code |
Definition at line 226 of file HTTPResponseHeader.h.
|
inline |
Get the 3-digit status code.
The 3-digit status code indicates the disposition of the response.
Definition at line 175 of file HTTPResponseHeader.h.
|
inline |
Get the 3-digit status code.
The 3-digit status code indicates the disposition of the response.
status_code | The 3-digit HTTP status code |
Definition at line 215 of file HTTPResponseHeader.h.
|
virtual |
Write this object to a stream.
Subclasses must implement this function.
out | The ostream to which to write. |
Implements cgicc::MStreamable.
HTTPResponseHeader & cgicc::HTTPResponseHeader::setCookie | ( | const HTTPCookie & | cookie | ) |
Set a cookie to go out with this HTTPResponseHeader.
cookie | The HTTPCookie to set |