Home
HTTP module

Response

HTTP response message with status, reason phrase, headers, and body metadata.

Response

#include <icy/http/response.h>
class Response

Defined in src/http/include/icy/http/response.h:78

Inherits: Message

HTTP response message with status, reason phrase, headers, and body metadata.

List of all members

NameKindOwner
operator<<friendDeclared here
ResponsefunctionDeclared here
ResponsefunctionDeclared here
ResponsefunctionDeclared here
ResponsefunctionDeclared here
ResponsefunctionDeclared here
~ResponsefunctionDeclared here
setStatusfunctionDeclared here
getStatusfunctionDeclared here
setReasonfunctionDeclared here
getReasonfunctionDeclared here
setStatusAndReasonfunctionDeclared here
setDatefunctionDeclared here
getDatefunctionDeclared here
addCookiefunctionDeclared here
getCookiesfunctionDeclared here
writefunctionDeclared here
writefunctionDeclared here
writefunctionDeclared here
successfunctionDeclared here
_statusvariableDeclared here
_reasonvariableDeclared here
setVersionfunctionInherited from Message
getVersionfunctionInherited from Message
setContentLengthfunctionInherited from Message
getContentLengthfunctionInherited from Message
hasContentLengthfunctionInherited from Message
setTransferEncodingfunctionInherited from Message
getTransferEncodingfunctionInherited from Message
setChunkedTransferEncodingfunctionInherited from Message
isChunkedTransferEncodingfunctionInherited from Message
setContentTypefunctionInherited from Message
getContentTypefunctionInherited from Message
setKeepAlivefunctionInherited from Message
getKeepAlivefunctionInherited from Message
writefunctionInherited from Message
writefunctionInherited from Message
writefunctionInherited from Message
HTTP_1_0variableInherited from Message
HTTP_1_1variableInherited from Message
IDENTITY_TRANSFER_ENCODINGvariableInherited from Message
CHUNKED_TRANSFER_ENCODINGvariableInherited from Message
UNKNOWN_CONTENT_LENGTHvariableInherited from Message
UNKNOWN_CONTENT_TYPEvariableInherited from Message
CONTENT_LENGTHvariableInherited from Message
CONTENT_TYPEvariableInherited from Message
TRANSFER_ENCODINGvariableInherited from Message
CONNECTIONvariableInherited from Message
CONNECTION_KEEP_ALIVEvariableInherited from Message
CONNECTION_CLOSEvariableInherited from Message
EMPTYvariableInherited from Message
_versionvariableInherited from Message
MessagefunctionInherited from Message
MessagefunctionInherited from Message
~MessagefunctionInherited from Message
NVCollectionfunctionInherited from NVCollection
NVCollectionfunctionInherited from NVCollection
NVCollectionfunctionInherited from NVCollection
~NVCollectionfunctionInherited from NVCollection
operator=functionInherited from NVCollection
operator=functionInherited from NVCollection
operator[]functionInherited from NVCollection
setfunctionInherited from NVCollection
addfunctionInherited from NVCollection
addfunctionInherited from NVCollection
getfunctionInherited from NVCollection
getfunctionInherited from NVCollection
hasfunctionInherited from NVCollection
findfunctionInherited from NVCollection
beginfunctionInherited from NVCollection
endfunctionInherited from NVCollection
emptyfunctionInherited from NVCollection
sizefunctionInherited from NVCollection
erasefunctionInherited from NVCollection
clearfunctionInherited from NVCollection
MaptypedefInherited from NVCollection
IteratortypedefInherited from NVCollection
ConstIteratortypedefInherited from NVCollection
_mapvariableInherited from NVCollection

Inherited from Message

KindNameDescription
functionsetVersionSets the HTTP version for this message.
functiongetVersion constReturns the HTTP version for this message.
functionsetContentLengthSets the Content-Length header.
functiongetContentLength constReturns the content length for this message, which may be UNKNOWN_CONTENT_LENGTH if no Content-Length header is present.
functionhasContentLength constReturns true if a Content-Length header is present.
functionsetTransferEncodingSets the transfer encoding for this message.
functiongetTransferEncoding constReturns the transfer encoding used for this message.
functionsetChunkedTransferEncodingIf flag is true, sets the Transfer-Encoding header to chunked. Otherwise, removes the Transfer-Encoding header.
functionisChunkedTransferEncoding constReturns true if the Transfer-Encoding header is set and its value is chunked.
functionsetContentTypeSets the content type for this message.
functiongetContentType constReturns the content type for this message.
functionsetKeepAliveSets the value of the Connection header field.
functiongetKeepAlive constReturns true if
functionwrite virtual constWrites the message header to the given output stream.
functionwrite virtual constWrites the message header to the given output string.
functionwrite virtual constWrites the message header directly into a byte buffer.
variableHTTP_1_0 static
variableHTTP_1_1 static
variableIDENTITY_TRANSFER_ENCODING static
variableCHUNKED_TRANSFER_ENCODING static
variableUNKNOWN_CONTENT_LENGTH static
variableUNKNOWN_CONTENT_TYPE static
variableCONTENT_LENGTH static
variableCONTENT_TYPE static
variableTRANSFER_ENCODING static
variableCONNECTION static
variableCONNECTION_KEEP_ALIVE static
variableCONNECTION_CLOSE static
variableEMPTY static
variable_version
functionMessageCreates the Message with version HTTP/1.0.
functionMessageCreates the Message and sets the version.
function~Message virtualDestroys the Message.

Inherited from NVCollection

KindNameDescription
functionNVCollection inline
functionNVCollection inline
functionNVCollection inline noexcept
function~NVCollection virtual inline
functionoperator=Assigns the name-value pairs of another NVCollection to this one.
functionoperator= noexcept
functionoperator[] constReturns the value of the (first) name-value pair with the given name.
functionsetSets the value of the (first) name-value pair with the given name.
functionaddAdds a new name-value pair with the given name and value.
functionaddAdds a new name-value pair using move semantics.
functionget constReturns the value of the first name-value pair with the given name.
functionget constReturns the value of the first name-value pair with the given name. If no value with the given name has been found, the defaultValue is returned.
functionhas constReturns true if there is at least one name-value pair with the given name.
functionfind constReturns an iterator pointing to the first name-value pair with the given name.
functionbegin constReturns an iterator pointing to the begin of the name-value pair collection.
functionend constReturns an iterator pointing to the end of the name-value pair collection.
functionempty constReturns true iff the header does not have any content.
functionsize constReturns the number of name-value pairs in the collection.
functioneraseRemoves all name-value pairs with the given name.
functionclearRemoves all name-value pairs and their values.
typedefMap
typedefIterator
typedefConstIterator
variable_map

Friends

NameDescription
operator<< inline

operator<<

inline

friend inline std::ostream & operator<<(std::ostream & stream, const Response & res)

Defined in src/http/include/icy/http/response.h:145

Public Methods

ReturnNameDescription
ResponseCreates the Response with OK status.
ResponseCreates the Response with the given status and reason phrase.
ResponseCreates the Response with the given version, status and reason phrase.
ResponseCreates the Response with the given status and an appropriate reason phrase.
ResponseCreates the Response with the given version, status and an appropriate reason phrase.
~Response virtualDestroys the Response.
voidsetStatusSets the HTTP status code.
StatusCodegetStatus constReturns the HTTP status code.
voidsetReasonSets the HTTP reason phrase.
const std::string &getReason constReturns the HTTP reason phrase.
voidsetStatusAndReasonSets the HTTP status code and reason phrase.
voidsetDateSets the Date header to the given date/time value.
TimestampgetDate constReturns the value of the Date header.
voidaddCookieAdds the cookie to the response by adding a Set-Cookie header.
voidgetCookies constReturns a vector with all the cookies set in the response header.
voidwrite virtual constWrites the HTTP response headers to the given output stream.
voidwrite virtual constWrites the HTTP response headers to the given output string.
voidwrite virtual constWrites the HTTP response headers directly into a byte buffer.
boolsuccess virtual constReturns true if the HTTP response code was successful (< 400).

Response

Response()

Defined in src/http/include/icy/http/response.h:82

Creates the Response with OK status.


Response

Response(StatusCode status, const std::string & reason)

Defined in src/http/include/icy/http/response.h:85

Creates the Response with the given status and reason phrase.


Response

Response(const std::string & version, StatusCode status, const std::string & reason)

Defined in src/http/include/icy/http/response.h:88

Creates the Response with the given version, status and reason phrase.


Response

Response(StatusCode status)

Defined in src/http/include/icy/http/response.h:92

Creates the Response with the given status and an appropriate reason phrase.


Response

Response(const std::string & version, StatusCode status)

Defined in src/http/include/icy/http/response.h:96

Creates the Response with the given version, status and an appropriate reason phrase.


~Response

virtual

virtual ~Response()

Defined in src/http/include/icy/http/response.h:99

Destroys the Response.


setStatus

void setStatus(StatusCode status)

Defined in src/http/include/icy/http/response.h:104

Sets the HTTP status code.

The reason phrase is set according to the status code.


getStatus

const

StatusCode getStatus() const

Defined in src/http/include/icy/http/response.h:107

Returns the HTTP status code.


setReason

void setReason(const std::string & reason)

Defined in src/http/include/icy/http/response.h:110

Sets the HTTP reason phrase.


getReason

const

const std::string & getReason() const

Defined in src/http/include/icy/http/response.h:113

Returns the HTTP reason phrase.


setStatusAndReason

void setStatusAndReason(StatusCode status, const std::string & reason)

Defined in src/http/include/icy/http/response.h:116

Sets the HTTP status code and reason phrase.


setDate

void setDate(const Timestamp & dateTime)

Defined in src/http/include/icy/http/response.h:119

Sets the Date header to the given date/time value.


getDate

const

Timestamp getDate() const

Defined in src/http/include/icy/http/response.h:122

Returns the value of the Date header.


addCookie

void addCookie(const Cookie & cookie)

Defined in src/http/include/icy/http/response.h:126

Adds the cookie to the response by adding a Set-Cookie header.


getCookies

const

void getCookies(std::vector< Cookie > & cookies) const

Defined in src/http/include/icy/http/response.h:131

Returns 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) const

Defined in src/http/include/icy/http/response.h:134

Writes the HTTP response headers to the given output stream.

Reimplements

write

virtual const

virtual void write(std::string & str) const

Defined in src/http/include/icy/http/response.h:137

Writes the HTTP response headers to the given output string.

Reimplements

write

virtual const

virtual void write(Buffer & buf) const

Defined in src/http/include/icy/http/response.h:140

Writes the HTTP response headers directly into a byte buffer.

Reimplements

success

virtual const

virtual bool success() const

Defined in src/http/include/icy/http/response.h:143

Returns true if the HTTP response code was successful (< 400).

Private Attributes

ReturnNameDescription
StatusCode_status
std::string_reason

_status

StatusCode _status

Defined in src/http/include/icy/http/response.h:152


_reason

std::string _reason

Defined in src/http/include/icy/http/response.h:153