Response.hpp

This File On Github
Ask A Question

API: latest
module: oatpp
#include "oatpp/web/protocol/http/incoming/Response.hpp"

Response

Class http::incoming::Response AKA IncomingResponse represents server's incoming response

namespace oatpp { namespace web { namespace protocol { namespace http { namespace incoming { 
  class Response : public oatpp::base::Countable {}
}}}}}

Methods

Return Type Name Summary
[none] Response Constructor.
std::shared_ptr<Response> createShared Create shared Response.
v_int32 getStatusCode Get http status code.
oatpp::String getStatusDescription Get http status description.
const http::Headers& getHeaders Get response http headers as oatpp::web::protocol::http::Headers.
oatpp::String getHeader Get header value
std::shared_ptr<oatpp::data::stream::InputStream> getBodyStream Get raw body stream.
std::shared_ptr<const http::incoming::BodyDecoder> getBodyDecoder Get body decoder configured for this response.
void transferBody Transfer body.
void transferBodyToStream Decode and transfer body to toStream.
oatpp::String readBodyToString Decode and read body to oatpp::String.
Type::ObjectWrapper readBodyToDto Read body stream, decode, and deserialize it as DTO Object (see Data Transfer Object (DTO)).
async::CoroutineStarter transferBodyAsync Transfer body in Asynchronous manner.
oatpp::async::CoroutineStarter transferBodyToStreamAsync Same as Response::readBodyToDto() but Async.
oatpp::async::CoroutineStarterForResult<const oatpp::String&> readBodyToStringAsync Same as Response::readBodyToString() but Async.
oatpp::async::CoroutineStarterForResult<const typenameDtoType::ObjectWrapper&> readBodyToDtoAsync Same as Response::readBodyToDto() but Async.

Response::Response

Constructor.

Response(v_int32 statusCode,
         const oatpp::String& statusDescription,
         const http::Headers& headers,
         const std::shared_ptr<oatpp::data::stream::InputStream>& bodyStream,
         const std::shared_ptr<const http::incoming::BodyDecoder>& bodyDecoder)

Response::createShared

Create shared Response.

static std::shared_ptr<Response> createShared(v_int32 statusCode,
                                              const oatpp::String& statusDescription,
                                              const http::Headers& headers,
                                              const std::shared_ptr<oatpp::data::stream::InputStream>& bodyStream,
                                              const std::shared_ptr<const http::incoming::BodyDecoder>& bodyDecoder)

Response::getStatusCode

Get http status code.

  • @return - http status code.

v_int32 getStatusCode() const

Response::getStatusDescription

Get http status description.

  • @return - http status description.

oatpp::String getStatusDescription() const

Response::getHeaders

Get response http headers as oatpp::web::protocol::http::Headers.

const http::Headers& getHeaders() const

Response::getHeader

Get header value

oatpp::String getHeader(const oatpp::data::share::StringKeyLabelCI_FAST& headerName) const

Response::getBodyStream

Get raw body stream.

std::shared_ptr<oatpp::data::stream::InputStream> getBodyStream() const

Response::getBodyDecoder

Get body decoder configured for this response.

std::shared_ptr<const http::incoming::BodyDecoder> getBodyDecoder() const

Response::transferBody

Transfer body.
Read body chunk by chunk and pass chunks to the writeCallback.

void transferBody(data::stream::WriteCallback* writeCallback) const

Response::transferBodyToStream

Decode and transfer body to toStream. Use case example - stream huge body directly to file using relatively small buffer.

void transferBodyToStream(oatpp::data::stream::OutputStream* toStream) const

Response::readBodyToString

Decode and read body to oatpp::String.

oatpp::String readBodyToString() const

Response::readBodyToDto

Read body stream, decode, and deserialize it as DTO Object (see Data Transfer Object (DTO)).

template<class Type>
typename Type::ObjectWrapper readBodyToDto(oatpp::data::mapping::ObjectMapper* objectMapper) const

Response::transferBodyAsync

Transfer body in Asynchronous manner.
Read body chunk by chunk and pass chunks to the writeCallback.

async::CoroutineStarter transferBodyAsync(const std::shared_ptr<data::stream::AsyncWriteCallback>& writeCallback) const

Response::transferBodyToStreamAsync

Same as Response::readBodyToDto() but Async.

oatpp::async::CoroutineStarter transferBodyToStreamAsync(const std::shared_ptr<oatpp::data::stream::OutputStream>& toStream) const

Response::readBodyToStringAsync

Same as Response::readBodyToString() but Async.

  • @return - oatpp::async::CoroutineStarterForResult.

oatpp::async::CoroutineStarterForResult<const oatpp::String&> readBodyToStringAsync() const

Response::readBodyToDtoAsync

Same as Response::readBodyToDto() but Async.

template<class DtoType>
oatpp::async::CoroutineStarterForResult<const typename DtoType::ObjectWrapper&>
readBodyToDtoAsync(const std::shared_ptr<oatpp::data::mapping::ObjectMapper>& objectMapper) const