# 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.

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.

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.

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)).

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.

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.

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