Home
HTTP module

Message

The base class for Request and Response.

Message

#include <icy/http/message.h>
class Message

Defined in src/http/include/icy/http/message.h:28

Inherits: NVCollection Subclassed by: Request, Response

The base class for Request and Response.

Defines the common properties of all HTTP messages. These are version, content length, content type and transfer encoding.

List of all members

NameKindOwner
setVersionfunctionDeclared here
getVersionfunctionDeclared here
setContentLengthfunctionDeclared here
getContentLengthfunctionDeclared here
hasContentLengthfunctionDeclared here
setTransferEncodingfunctionDeclared here
getTransferEncodingfunctionDeclared here
setChunkedTransferEncodingfunctionDeclared here
isChunkedTransferEncodingfunctionDeclared here
setContentTypefunctionDeclared here
getContentTypefunctionDeclared here
setKeepAlivefunctionDeclared here
getKeepAlivefunctionDeclared here
writefunctionDeclared here
writefunctionDeclared here
writefunctionDeclared here
HTTP_1_0variableDeclared here
HTTP_1_1variableDeclared here
IDENTITY_TRANSFER_ENCODINGvariableDeclared here
CHUNKED_TRANSFER_ENCODINGvariableDeclared here
UNKNOWN_CONTENT_LENGTHvariableDeclared here
UNKNOWN_CONTENT_TYPEvariableDeclared here
CONTENT_LENGTHvariableDeclared here
CONTENT_TYPEvariableDeclared here
TRANSFER_ENCODINGvariableDeclared here
CONNECTIONvariableDeclared here
CONNECTION_KEEP_ALIVEvariableDeclared here
CONNECTION_CLOSEvariableDeclared here
EMPTYvariableDeclared here
_versionvariableDeclared here
MessagefunctionDeclared here
MessagefunctionDeclared here
~MessagefunctionDeclared here
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 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

Public Methods

ReturnNameDescription
voidsetVersionSets the HTTP version for this message.
const std::string &getVersion constReturns the HTTP version for this message.
voidsetContentLengthSets the Content-Length header.
uint64_tgetContentLength constReturns the content length for this message, which may be UNKNOWN_CONTENT_LENGTH if no Content-Length header is present.
boolhasContentLength constReturns true if a Content-Length header is present.
voidsetTransferEncodingSets the transfer encoding for this message.
const std::string &getTransferEncoding constReturns the transfer encoding used for this message.
voidsetChunkedTransferEncodingIf flag is true, sets the Transfer-Encoding header to chunked. Otherwise, removes the Transfer-Encoding header.
boolisChunkedTransferEncoding constReturns true if the Transfer-Encoding header is set and its value is chunked.
voidsetContentTypeSets the content type for this message.
const std::string &getContentType constReturns the content type for this message.
voidsetKeepAliveSets the value of the Connection header field.
boolgetKeepAlive constReturns true if
voidwrite virtual constWrites the message header to the given output stream.
voidwrite virtual constWrites the message header to the given output string.
voidwrite virtual constWrites the message header directly into a byte buffer.

setVersion

void setVersion(const std::string & version)

Defined in src/http/include/icy/http/message.h:32

Sets the HTTP version for this message.


getVersion

const

const std::string & getVersion() const

Defined in src/http/include/icy/http/message.h:35

Returns the HTTP version for this message.


setContentLength

void setContentLength(uint64_t length)

Defined in src/http/include/icy/http/message.h:41

Sets the Content-Length header.

If length is UNKNOWN_CONTENT_LENGTH, removes the Content-Length header.


getContentLength

const

uint64_t getContentLength() const

Defined in src/http/include/icy/http/message.h:46

Returns the content length for this message, which may be UNKNOWN_CONTENT_LENGTH if no Content-Length header is present.


hasContentLength

const

bool hasContentLength() const

Defined in src/http/include/icy/http/message.h:49

Returns true if a Content-Length header is present.


setTransferEncoding

void setTransferEncoding(const std::string & transferEncoding)

Defined in src/http/include/icy/http/message.h:55

Sets the transfer encoding for this message.

The value should be either IDENTITY_TRANSFER_CODING or CHUNKED_TRANSFER_CODING.


getTransferEncoding

const

const std::string & getTransferEncoding() const

Defined in src/http/include/icy/http/message.h:62

Returns the transfer encoding used for this message.

Normally, this is the value of the Transfer-Encoding header field. If no such field is present, returns IDENTITY_TRANSFER_CODING.


setChunkedTransferEncoding

void setChunkedTransferEncoding(bool flag)

Defined in src/http/include/icy/http/message.h:66

If flag is true, sets the Transfer-Encoding header to chunked. Otherwise, removes the Transfer-Encoding header.


isChunkedTransferEncoding

const

bool isChunkedTransferEncoding() const

Defined in src/http/include/icy/http/message.h:70

Returns true if the Transfer-Encoding header is set and its value is chunked.


setContentType

void setContentType(const std::string & contentType)

Defined in src/http/include/icy/http/message.h:76

Sets the content type for this message.

Specify NO_CONTENT_TYPE to remove the Content-Type header.


getContentType

const

const std::string & getContentType() const

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

Returns the content type for this message.

If no Content-Type header is present, returns UNKNOWN_CONTENT_TYPE.


setKeepAlive

void setKeepAlive(bool keepAlive)

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

Sets the value of the Connection header field.

The value is set to "Keep-Alive" if keepAlive is true, or to "Close" otherwise.


getKeepAlive

const

bool getKeepAlive() const

Defined in src/http/include/icy/http/message.h:94

Returns true if

  • the message has a Connection header field and its value is "Keep-Alive"

  • the message is an HTTP/1.1 message and no Connection header is set Returns false otherwise.


write

virtual const

virtual void write(std::ostream & ostr) const

Defined in src/http/include/icy/http/message.h:102

Writes the message header to the given output stream.

The format is one name-value pair per line, with name and value separated by a colon and lines delimited by a carriage return and a linefeed character. See RFC 2822 for details.

Reimplemented by

write

virtual const

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

Defined in src/http/include/icy/http/message.h:105

Writes the message header to the given output string.

Reimplemented by

write

virtual const

virtual void write(Buffer & buf) const

Defined in src/http/include/icy/http/message.h:108

Writes the message header directly into a byte buffer.

Reimplemented by

Public Static Attributes

ReturnNameDescription
const std::stringHTTP_1_0 static
const std::stringHTTP_1_1 static
const std::stringIDENTITY_TRANSFER_ENCODING static
const std::stringCHUNKED_TRANSFER_ENCODING static
const intUNKNOWN_CONTENT_LENGTH static
const std::stringUNKNOWN_CONTENT_TYPE static
const std::stringCONTENT_LENGTH static
const std::stringCONTENT_TYPE static
const std::stringTRANSFER_ENCODING static
const std::stringCONNECTION static
const std::stringCONNECTION_KEEP_ALIVE static
const std::stringCONNECTION_CLOSE static
const std::stringEMPTY static

HTTP_1_0

static

const std::string HTTP_1_0

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


HTTP_1_1

static

const std::string HTTP_1_1

Defined in src/http/include/icy/http/message.h:111


IDENTITY_TRANSFER_ENCODING

static

const std::string IDENTITY_TRANSFER_ENCODING

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


CHUNKED_TRANSFER_ENCODING

static

const std::string CHUNKED_TRANSFER_ENCODING

Defined in src/http/include/icy/http/message.h:114


UNKNOWN_CONTENT_LENGTH

static

const int UNKNOWN_CONTENT_LENGTH

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


UNKNOWN_CONTENT_TYPE

static

const std::string UNKNOWN_CONTENT_TYPE

Defined in src/http/include/icy/http/message.h:117


CONTENT_LENGTH

static

const std::string CONTENT_LENGTH

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


CONTENT_TYPE

static

const std::string CONTENT_TYPE

Defined in src/http/include/icy/http/message.h:120


TRANSFER_ENCODING

static

const std::string TRANSFER_ENCODING

Defined in src/http/include/icy/http/message.h:121


CONNECTION

static

const std::string CONNECTION

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


CONNECTION_KEEP_ALIVE

static

const std::string CONNECTION_KEEP_ALIVE

Defined in src/http/include/icy/http/message.h:124


CONNECTION_CLOSE

static

const std::string CONNECTION_CLOSE

Defined in src/http/include/icy/http/message.h:125


EMPTY

static

const std::string EMPTY

Defined in src/http/include/icy/http/message.h:127

Protected Attributes

ReturnNameDescription
std::string_version

_version

std::string _version

Defined in src/http/include/icy/http/message.h:130

Protected Methods

ReturnNameDescription
MessageCreates the Message with version HTTP/1.0.
MessageCreates the Message and sets the version.
~Message virtualDestroys the Message.

Message

Message()

Defined in src/http/include/icy/http/message.h:133

Creates the Message with version HTTP/1.0.


Message

Message(const std::string & version)

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

Creates the Message and sets the version.


~Message

virtual

virtual ~Message()

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

Destroys the Message.