# BodyDecoder.hpp
This File On Github
Ask A Question
API: latest
module: oatpp
#include "oatpp/web/protocol/http/incoming/BodyDecoder.hpp"
# BodyDecoder
Abstract BodyDecoder. Body Decoder is responsible to decode body of incoming request. For example if you receive chunked-encoded body, you have to decode it in order to get "plain" body. You may extend this class in order to customize body-decoding process.
namespace oatpp { namespace web { namespace protocol { namespace http { namespace incoming {
class BodyDecoder {}
}}}}}
# Methods
Return Type | Name | Summary |
---|---|---|
[none] | ~BodyDecoder | Virtual destructor. |
void | decode | Implement this method! Decode bodyStream and write decoded data to toStream. |
oatpp::async::CoroutineStarter | decodeAsync | Implement this method! Same as BodyDecoder::decode() but Async. |
oatpp::String | decodeToString | Read body stream and decode it to string. |
Wrapper | decodeToDto | Read body stream, decode, and deserialize it as DTO Object (see Data Transfer Object (DTO)). |
oatpp::async::CoroutineStarterForResult<const oatpp::String&> | decodeToStringAsync | Same as BodyDecoder::decodeToString() but Async. |
oatpp::async::CoroutineStarterForResult<const Wrapper&> | decodeToDtoAsync | Same as BodyDecoder::decodeToDto() but Async. |
# BodyDecoder::~BodyDecoder
Virtual destructor.
virtual ~BodyDecoder() = default
# BodyDecoder::decode
Implement this method! Decode bodyStream and write decoded data to toStream.
- @param headers - Headers map. oatpp::web::protocol::http::Headers.
- @param bodyStream - pointer to oatpp::data::stream::InputStream.
- @param writeCallback - oatpp::data::stream::WriteCallback.
- @param connection
virtual void decode(const Headers& headers,
data::stream::InputStream* bodyStream,
data::stream::WriteCallback* writeCallback,
data::stream::IOStream* connection) const = 0
# BodyDecoder::decodeAsync
Implement this method! Same as BodyDecoder::decode() but Async.
- @param headers - Headers map. oatpp::web::protocol::http::Headers.
- @param bodyStream -
std::shared_ptr
to oatpp::data::stream::InputStream. - @param writeCallback -
std::shared_ptr
to oatpp::data::stream::WriteCallback. - @param connection
- @return - oatpp::async::CoroutineStarter.
virtual oatpp::async::CoroutineStarter decodeAsync(const Headers& headers,
const std::shared_ptr<data::stream::InputStream>& bodyStream,
const std::shared_ptr<data::stream::WriteCallback>& writeCallback,
const std::shared_ptr<data::stream::IOStream>& connection) const = 0
# BodyDecoder::decodeToString
Read body stream and decode it to string.
- @param headers - Headers map. oatpp::web::protocol::http::Headers.
- @param bodyStream - pointer to oatpp::data::stream::InputStream.
- @param connection
- @return - oatpp::String;.
oatpp::String decodeToString(const Headers& headers,
data::stream::InputStream* bodyStream,
data::stream::IOStream* connection) const
# BodyDecoder::decodeToDto
Read body stream, decode, and deserialize it as DTO Object (see Data Transfer Object (DTO)).
- @tparam Wrapper - ObjectWrapper type.
- @param headers - Headers map. oatpp::web::protocol::http::Headers.
- @param bodyStream - pointer to oatpp::data::stream::InputStream.
- @param connection
- @param objectMapper - pointer to oatpp::data::mapping::ObjectMapper.
- @return - deserialized DTO object.
template<class Wrapper>
Wrapper decodeToDto(const Headers& headers,
data::stream::InputStream* bodyStream,
data::stream::IOStream* connection,
data::mapping::ObjectMapper* objectMapper) const
# BodyDecoder::decodeToStringAsync
Same as BodyDecoder::decodeToString() but Async.
- @param headers - Headers map. oatpp::web::protocol::http::Headers.
- @param bodyStream -
std::shared_ptr
to oatpp::data::stream::InputStream. - @param connection
- @return - oatpp::async::CoroutineStarterForResult.
oatpp::async::CoroutineStarterForResult<const oatpp::String&>
decodeToStringAsync(const Headers& headers,
const std::shared_ptr<data::stream::InputStream>& bodyStream,
const std::shared_ptr<data::stream::IOStream>& connection) const
# BodyDecoder::decodeToDtoAsync
Same as BodyDecoder::decodeToDto() but Async.
- @tparam Wrapper - ObjectWrapper type.
- @param headers - Headers map. oatpp::web::protocol::http::Headers.
- @param bodyStream -
std::shared_ptr
to oatpp::data::stream::InputStream. - @param connection
- @param objectMapper -
std::shared_ptr
to oatpp::data::mapping::ObjectMapper. - @return - oatpp::async::CoroutineStarterForResult.
template<class Wrapper>
oatpp::async::CoroutineStarterForResult<const Wrapper&>
decodeToDtoAsync(const Headers& headers,
const std::shared_ptr<data::stream::InputStream>& bodyStream,
const std::shared_ptr<data::stream::IOStream>& connection,
const std::shared_ptr<data::mapping::ObjectMapper>& objectMapper) const