Home
HTTP module

Request

HTTP request message with method, URI, headers, and optional body.

Request

#include <icy/http/request.h>
class Request

Defined in src/http/include/icy/http/request.h:44

Inherits: Message

HTTP request message with method, URI, headers, and optional body.

In addition to the properties common to all HTTP messages, an HTTP request has a method (e.g. GET, HEAD, POST, etc.) and a request URI.

List of all members

NameKindOwner
operator<<friendDeclared here
RequestfunctionDeclared here
RequestfunctionDeclared here
RequestfunctionDeclared here
RequestfunctionDeclared here
~RequestfunctionDeclared here
setMethodfunctionDeclared here
getMethodfunctionDeclared here
setURIfunctionDeclared here
appendURIfunctionDeclared here
getURIfunctionDeclared here
setHostfunctionDeclared here
setHostfunctionDeclared here
getHostfunctionDeclared here
setCookiesfunctionDeclared here
getCookiesfunctionDeclared here
getURIParametersfunctionDeclared here
hasCredentialsfunctionDeclared here
getCredentialsfunctionDeclared here
setCredentialsfunctionDeclared here
hasProxyCredentialsfunctionDeclared here
getProxyCredentialsfunctionDeclared here
setProxyCredentialsfunctionDeclared here
writefunctionDeclared here
writefunctionDeclared here
writefunctionDeclared here
getCredentialsfunctionDeclared here
setCredentialsfunctionDeclared here
_methodvariableDeclared here
_urivariableDeclared 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 Request & req)

Defined in src/http/include/icy/http/request.h:146

Public Methods

ReturnNameDescription
RequestCreates a GET / HTTP/1.1 HTTP request.
RequestCreates a GET / HTTP/1.x request with the given version (HTTP/1.0 or HTTP/1.1).
RequestCreates an HTTP/1.0 request with the given method and URI.
RequestCreates an HTTP request with the given method, URI and version.
~Request virtualDestroys the Request.
voidsetMethodSets the method.
const std::string &getMethod constReturns the method.
voidsetURISets the request URI.
voidappendURIAppends a fragment to the request URI. Used by the parser when llhttp splits the URL across callbacks.
const std::string &getURI constReturns the request URI.
voidsetHostSets the value of the Host header field.
voidsetHostSets the value of the Host header field.
const std::string &getHost constReturns the value of the Host header field.
voidsetCookiesAdds a Cookie header with the names and values from cookies.
voidgetCookies constFills cookies with the cookies extracted from the Cookie headers in the request.
voidgetURIParameters constReturns the request URI parameters.
boolhasCredentials constReturns true if the request contains authentication information in the form of an Authorization header.
voidgetCredentials constReturns the authentication scheme and additional authentication information contained in this request.
voidsetCredentialsSets the authentication scheme and information for this request.
boolhasProxyCredentials constReturns true if the request contains proxy authentication information in the form of an Proxy-Authorization header.
voidgetProxyCredentials constReturns the proxy authentication scheme and additional proxy authentication information contained in this request.
voidsetProxyCredentialsSets the proxy authentication scheme and information for this request.
voidwrite virtual constWrites the HTTP request to the given output stream.
voidwrite virtual constWrites the HTTP request to the given output string.
voidwrite virtual constWrites the HTTP request directly into a byte buffer.

Request

Request()

Defined in src/http/include/icy/http/request.h:48

Creates a GET / HTTP/1.1 HTTP request.


Request

Request(const std::string & version)

Defined in src/http/include/icy/http/request.h:52

Creates a GET / HTTP/1.x request with the given version (HTTP/1.0 or HTTP/1.1).


Request

Request(const std::string & method, const std::string & uri)

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

Creates an HTTP/1.0 request with the given method and URI.


Request

Request(const std::string & method, const std::string & uri, const std::string & version)

Defined in src/http/include/icy/http/request.h:58

Creates an HTTP request with the given method, URI and version.


~Request

virtual

virtual ~Request()

Defined in src/http/include/icy/http/request.h:61

Destroys the Request.


setMethod

void setMethod(const std::string & method)

Defined in src/http/include/icy/http/request.h:64

Sets the method.


getMethod

const

const std::string & getMethod() const

Defined in src/http/include/icy/http/request.h:67

Returns the method.


setURI

void setURI(std::string uri)

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

Sets the request URI.


appendURI

void appendURI(std::string_view uri)

Defined in src/http/include/icy/http/request.h:74

Appends a fragment to the request URI. Used by the parser when llhttp splits the URL across callbacks.


getURI

const

const std::string & getURI() const

Defined in src/http/include/icy/http/request.h:77

Returns the request URI.


setHost

void setHost(const std::string & host)

Defined in src/http/include/icy/http/request.h:80

Sets the value of the Host header field.


setHost

void setHost(const std::string & host, uint16_t port)

Defined in src/http/include/icy/http/request.h:87

Sets the value of the Host header field.

If the given port number is a non-standard port number (other than 80 or 443), it is included in the Host header field.


getHost

const

const std::string & getHost() const

Defined in src/http/include/icy/http/request.h:93

Returns the value of the Host header field.

Throws a NotFoundException if the request does not have a Host header field.


setCookies

void setCookies(const NVCollection & cookies)

Defined in src/http/include/icy/http/request.h:97

Adds a Cookie header with the names and values from cookies.


getCookies

const

void getCookies(NVCollection & cookies) const

Defined in src/http/include/icy/http/request.h:101

Fills cookies with the cookies extracted from the Cookie headers in the request.


getURIParameters

const

void getURIParameters(NVCollection & params) const

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

Returns the request URI parameters.


hasCredentials

const

bool hasCredentials() const

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

Returns true if the request contains authentication information in the form of an Authorization header.


getCredentials

const

void getCredentials(std::string & scheme, std::string & authInfo) const

Defined in src/http/include/icy/http/request.h:115

Returns the authentication scheme and additional authentication information contained in this request.

Throws a std::exception if no authentication information is contained in the request.


setCredentials

void setCredentials(std::string_view scheme, std::string_view authInfo)

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

Sets the authentication scheme and information for this request.


hasProxyCredentials

const

bool hasProxyCredentials() const

Defined in src/http/include/icy/http/request.h:123

Returns true if the request contains proxy authentication information in the form of an Proxy-Authorization header.


getProxyCredentials

const

void getProxyCredentials(std::string & scheme, std::string & authInfo) const

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

Returns the proxy authentication scheme and additional proxy authentication information contained in this request.

Throws a std::exception if no proxy authentication information is contained in the request.


setProxyCredentials

void setProxyCredentials(std::string_view scheme, std::string_view authInfo)

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

Sets the proxy authentication scheme and information for this request.


write

virtual const

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

Defined in src/http/include/icy/http/request.h:138

Writes the HTTP request to the given output stream.

Reimplements

write

virtual const

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

Defined in src/http/include/icy/http/request.h:141

Writes the HTTP request to the given output string.

Reimplements

write

virtual const

virtual void write(Buffer & buf) const

Defined in src/http/include/icy/http/request.h:144

Writes the HTTP request directly into a byte buffer.

Reimplements

Protected Methods

ReturnNameDescription
voidgetCredentials constReturns the authentication scheme and additional authentication information contained in the given header of request.
voidsetCredentialsWrites the authentication scheme and information for this request to the given header.

getCredentials

const

void getCredentials(const std::string & header, std::string & scheme, std::string & authInfo) const

Defined in src/http/include/icy/http/request.h:158

Returns the authentication scheme and additional authentication information contained in the given header of request.

Throws a NotAuthenticatedException if no authentication information is contained in the request.


setCredentials

void setCredentials(const std::string & header, std::string_view scheme, std::string_view authInfo)

Defined in src/http/include/icy/http/request.h:162

Writes the authentication scheme and information for this request to the given header.

Private Attributes

ReturnNameDescription
std::string_method
std::string_uri

_method

std::string _method

Defined in src/http/include/icy/http/request.h:165


_uri

std::string _uri

Defined in src/http/include/icy/http/request.h:166