Response
Response
#include <icy/http/response.h>Inherits:
Message
HTTP response message with status, reason phrase, headers, and body metadata.
Public Methods
| Return | Name | Description |
|---|---|---|
Response | Creates the Response with OK status. | |
Response | Creates the Response with the given status and reason phrase. | |
Response | Creates the Response with the given version, status and reason phrase. | |
Response | Creates the Response with the given status and an appropriate reason phrase. | |
Response | Creates the Response with the given version, status and an appropriate reason phrase. | |
~Response virtual | Destroys the Response. | |
void | setStatus | Sets the HTTP status code. |
StatusCode | getStatus const | Returns the HTTP status code. |
void | setReason | Sets the HTTP reason phrase. |
const std::string & | getReason const | Returns the HTTP reason phrase. |
void | setStatusAndReason | Sets the HTTP status code and reason phrase. |
void | setDate | Sets the Date header to the given date/time value. |
Timestamp | getDate const | Returns the value of the Date header. |
void | addCookie | Adds the cookie to the response by adding a Set-Cookie header. |
void | getCookies const | Returns a vector with all the cookies set in the response header. |
void | write virtual const | Writes the HTTP response headers to the given output stream. |
void | write virtual const | Writes the HTTP response headers to the given output string. |
void | write virtual const | Writes the HTTP response headers directly into a byte buffer. |
bool | success virtual const | Returns true if the HTTP response code was successful (< 400). |
Response
Response()Creates the Response with OK status.
Response
Response(StatusCode status, const std::string & reason)Creates the Response with the given status and reason phrase.
Response
Response(const std::string & version, StatusCode status, const std::string & reason)Creates the Response with the given version, status and reason phrase.
Response
Response(StatusCode status)Creates the Response with the given status and an appropriate reason phrase.
Response
Response(const std::string & version, StatusCode status)Creates the Response with the given version, status and an appropriate reason phrase.
~Response
virtual
virtual ~Response()Destroys the Response.
setStatus
void setStatus(StatusCode status)Sets the HTTP status code.
The reason phrase is set according to the status code.
getStatus
const
StatusCode getStatus() constReturns the HTTP status code.
setReason
void setReason(const std::string & reason)Sets the HTTP reason phrase.
getReason
const
const std::string & getReason() constReturns the HTTP reason phrase.
setStatusAndReason
void setStatusAndReason(StatusCode status, const std::string & reason)Sets the HTTP status code and reason phrase.
setDate
void setDate(const Timestamp & dateTime)Sets the Date header to the given date/time value.
getDate
const
Timestamp getDate() constReturns the value of the Date header.
addCookie
void addCookie(const Cookie & cookie)Adds the cookie to the response by adding a Set-Cookie header.
getCookies
const
void getCookies(std::vector< Cookie > & cookies) constReturns a vector with all the cookies set in the response header.
May throw an exception in case of a malformed Set-Cookie header.
write
virtual const
virtual void write(std::ostream & ostr) constWrites the HTTP response headers to the given output stream.
write
virtual const
virtual void write(std::string & str) constWrites the HTTP response headers to the given output string.
write
virtual const
virtual void write(Buffer & buf) constWrites the HTTP response headers directly into a byte buffer.
success
virtual const
virtual bool success() constReturns true if the HTTP response code was successful (< 400).
Private Attributes
_status
StatusCode _status_reason
std::string _reason