# Request.hpp
This File On Github
Ask A Question
API: latest
module: oatpp
#include "oatpp/web/protocol/http/incoming/Request.hpp"
# Request
Class http::incoming::Request AKA IncomingRequest represents client's incoming request.
namespace oatpp { namespace web { namespace protocol { namespace http { namespace incoming {
class Request : public oatpp::base::Countable {}
}}}}}
# Methods
Return Type | Name | Summary |
---|---|---|
std::shared_ptr<oatpp::data::stream::IOStream> | getConnection | Get raw connection stream. |
const http::QueryParams& | getQueryParameters | Get map of url query parameters. |
oatpp::String | getQueryParameter | Multiple implementations:
|
const http::RequestStartingLine& | getStartingLine | Get request starting line. (method, path, protocol) |
void | setPathVariables | Set request path variables. |
const url::mapping::Pattern::MatchMap& | getPathVariables | Get path variables according to path-pattern. |
const http::Headers& | getHeaders | Get request's headers map |
std::shared_ptr<oatpp::data::stream::InputStream> | getBodyStream | Get request's body stream |
std::shared_ptr<const http::incoming::BodyDecoder> | getBodyDecoder | Get body decoder. |
void | putHeader | Add http header. |
bool | putHeaderIfNotExists | Add http header if not already exists. |
bool | putOrReplaceHeader | Replaces or adds header. |
bool | putOrReplaceHeader_Unsafe | Replaces or adds header. |
void | putHeader_Unsafe | Add http header. |
bool | putHeaderIfNotExists_Unsafe | Add http header if not already exists. |
oatpp::String | getHeader | Get header value |
oatpp::String | getPathVariable | Get path variable according to path-pattern |
oatpp::String | getPathTail | Get path tail according to path-pattern |
void | putBundleData | Put data to bundle. |
WrapperType | getBundleData | Get data from bundle by key. |
const data::Bundle& | getBundle | Get bundle object. |
void | transferBody | Transfer body. |
void | transferBodyToStream | Stream content of the body-stream to toStream |
oatpp::String | readBodyToString | Transfer body stream to string |
Wrapper | readBodyToDto | Transfer body to String and parse it as DTO |
async::CoroutineStarter | transferBodyAsync | Transfer body in Asynchronous manner. |
oatpp::async::CoroutineStarter | transferBodyToStreamAsync | Transfer body stream to toStream Async |
async::CoroutineStarterForResult<const oatpp::String&> | readBodyToStringAsync | Transfer body stream to string Async. |
oatpp::async::CoroutineStarterForResult<const Wrapper&> | readBodyToDtoAsync | Transfer body to String and parse it as DTO |
# Request::getConnection
Get raw connection stream.
- @return - std::shared_ptroatpp::data::stream::IOStream m_connection.
std::shared_ptr<oatpp::data::stream::IOStream> getConnection()
# Request::getQueryParameters
Get map of url query parameters. Query parameters will be lazy parsed from url "tail" Please note: lazy parsing of query parameters is not thread-safe!
- @return map<key, value> for "key=value"
const http::QueryParams& getQueryParameters() const
# Request::getQueryParameter
- Get query parameter value by name
- @param name
- @return query parameter value
oatpp::String getQueryParameter(const oatpp::data::share::StringKeyLabel& name) const
- Get query parameter value by name with defaultValue
- @param name
- @param defaultValue
- @return query parameter value or defaultValue if no such parameter found
oatpp::String getQueryParameter(const oatpp::data::share::StringKeyLabel& name, const oatpp::String& defaultValue) const
# Request::getStartingLine
Get request starting line. (method, path, protocol)
- @return starting line structure
const http::RequestStartingLine& getStartingLine() const
# Request::setPathVariables
Set request path variables.
- @param pathVariables - oatpp::web::url::mapping::Pattern::MatchMap.
void setPathVariables(const url::mapping::Pattern::MatchMap& pathVariables)
# Request::getPathVariables
Get path variables according to path-pattern.
Ex. given request path="/sum/19/1" for path-pattern="/sum/{a}/{b}"
getPathVariables().getVariable("a") == 19, getPathVariables().getVariable("b") == 1.
- @return url MatchMap
const url::mapping::Pattern::MatchMap& getPathVariables() const
# Request::getHeaders
Get request's headers map
- @return Headers map
const http::Headers& getHeaders() const
# Request::getBodyStream
Get request's body stream
- @return body stream
std::shared_ptr<oatpp::data::stream::InputStream> getBodyStream() const
# Request::getBodyDecoder
Get body decoder.
- @return Body decoder
std::shared_ptr<const http::incoming::BodyDecoder> getBodyDecoder() const
# Request::putHeader
Add http header.
- @param key - oatpp::String.
- @param value - oatpp::String.
void putHeader(const oatpp::String& key, const oatpp::String& value)
# Request::putHeaderIfNotExists
Add http header if not already exists.
- @param key - oatpp::String.
- @param value - oatpp::String.
- @return -
true
if header was added.
bool putHeaderIfNotExists(const oatpp::String& key, const oatpp::String& value)
# Request::putOrReplaceHeader
Replaces or adds header.
- @param key - oatpp::String.
- @param value - oatpp::String.
- @return -
true
if header was replaces,false
if header was added.
bool putOrReplaceHeader(const oatpp::String& key, const oatpp::String& value)
# Request::putOrReplaceHeader_Unsafe
Replaces or adds header.
- @param key - oatpp::data::share::StringKeyLabelCI.
- @param value - oatpp::data::share::StringKeyLabel.
- @return -
true
if header was replaces,false
if header was added.
bool putOrReplaceHeader_Unsafe(const oatpp::data::share::StringKeyLabelCI& key, const oatpp::data::share::StringKeyLabel& value)
# Request::putHeader_Unsafe
Add http header.
- @param key - oatpp::data::share::StringKeyLabelCI.
- @param value - oatpp::data::share::StringKeyLabel.
void putHeader_Unsafe(const oatpp::data::share::StringKeyLabelCI& key, const oatpp::data::share::StringKeyLabel& value)
# Request::putHeaderIfNotExists_Unsafe
Add http header if not already exists.
- @param key - oatpp::data::share::StringKeyLabelCI.
- @param value - oatpp::data::share::StringKeyLabel.
- @return -
true
if header was added.
bool putHeaderIfNotExists_Unsafe(const oatpp::data::share::StringKeyLabelCI& key, const oatpp::data::share::StringKeyLabel& value)
# Request::getHeader
Get header value
- @param headerName - oatpp::data::share::StringKeyLabelCI.
- @return - oatpp::String.
oatpp::String getHeader(const oatpp::data::share::StringKeyLabelCI& headerName) const
# Request::getPathVariable
Get path variable according to path-pattern
- @param name
- @return matched value for path-pattern
oatpp::String getPathVariable(const oatpp::data::share::StringKeyLabel& name) const
# Request::getPathTail
Get path tail according to path-pattern Ex. given request path="/hello/path/tail" for path-pattern="/hello/*" tail == "path/tail" note '/' symbol is required before '*'
- @return matched tail-value for path-pattern
oatpp::String getPathTail() const
# Request::putBundleData
Put data to bundle.
- @param key
- @param polymorph
void putBundleData(const oatpp::String& key, const oatpp::Void& polymorph)
# Request::getBundleData
Get data from bundle by key.
- @tparam WrapperType
- @param key
- @return
template<typename WrapperType>
WrapperType getBundleData(const oatpp::String& key) const
# Request::getBundle
Get bundle object.
- @return
const data::Bundle& getBundle() const
# Request::transferBody
Transfer body.
Read body chunk by chunk and pass chunks to the writeCallback
.
- @param writeCallback - oatpp::data::stream::WriteCallback.
void transferBody(const base::ObjectHandle<data::stream::WriteCallback>& writeCallback) const
# Request::transferBodyToStream
Stream content of the body-stream to toStream
- @param toStream
void transferBodyToStream(const base::ObjectHandle<data::stream::OutputStream>& toStream) const
# Request::readBodyToString
Transfer body stream to string
- @return body as string
oatpp::String readBodyToString() const
# Request::readBodyToDto
Transfer body to String and parse it as DTO
- @tparam Wrapper - ObjectWrapper type.
- @param objectMapper
- @return DTO
template<class Wrapper>
Wrapper readBodyToDto(const base::ObjectHandle<data::mapping::ObjectMapper>& objectMapper) const
# Request::transferBodyAsync
Transfer body in Asynchronous manner.
Read body chunk by chunk and pass chunks to the writeCallback
.
- @param writeCallback -
std::shared_ptr
to oatpp::data::stream::WriteCallback. - @return - oatpp::async::CoroutineStarter.
async::CoroutineStarter transferBodyAsync(const std::shared_ptr<data::stream::WriteCallback>& writeCallback) const
# Request::transferBodyToStreamAsync
Transfer body stream to toStream Async
- @param toStream
- @return - oatpp::async::CoroutineStarter.
oatpp::async::CoroutineStarter transferBodyToStreamAsync(const std::shared_ptr<oatpp::data::stream::OutputStream>& toStream) const
# Request::readBodyToStringAsync
Transfer body stream to string Async.
- @return - oatpp::async::CoroutineStarterForResult.
async::CoroutineStarterForResult<const oatpp::String&> readBodyToStringAsync() const
# Request::readBodyToDtoAsync
Transfer body to String and parse it as DTO
- @tparam Wrapper - DTO
ObjectWrapper
. - @param objectMapper
- @return - oatpp::async::CoroutineStarterForResult.
template<class Wrapper>
oatpp::async::CoroutineStarterForResult<const Wrapper&>
readBodyToDtoAsync(const std::shared_ptr<oatpp::data::mapping::ObjectMapper>& objectMapper) const