# 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.
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
void putBundleData Put data to bundle.
WrapperType getBundleData Get data from bundle by key.
const data::Bundle& getBundle Get bundle object.
std::shared_ptr<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.
Wrapper 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 Wrapper&> 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::putHeader

Add http header.

void putHeader(const oatpp::String& key, const oatpp::String& value)

# Response::putHeaderIfNotExists

Add http header if not already exists.

bool putHeaderIfNotExists(const oatpp::String& key, const oatpp::String& value)

# Response::putOrReplaceHeader

Replaces or adds header.

bool putOrReplaceHeader(const oatpp::String& key, const oatpp::String& value)

# Response::putOrReplaceHeader_Unsafe

Replaces or adds header.

bool putOrReplaceHeader_Unsafe(const oatpp::data::share::StringKeyLabelCI& key, const oatpp::data::share::StringKeyLabel& value)

# Response::putHeader_Unsafe

Add http header.

void putHeader_Unsafe(const oatpp::data::share::StringKeyLabelCI& key, const oatpp::data::share::StringKeyLabel& value)

# Response::putHeaderIfNotExists_Unsafe

Add http header if not already exists.

bool putHeaderIfNotExists_Unsafe(const oatpp::data::share::StringKeyLabelCI& key, const oatpp::data::share::StringKeyLabel& value)

# Response::getHeader

Get header value

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

# Response::putBundleData

Put data to bundle.

  • @param key
  • @param polymorph

void putBundleData(const oatpp::String& key, const oatpp::Void& polymorph)

# Response::getBundleData

Get data from bundle by key.

  • @tparam WrapperType
  • @param key
  • @return

template<typename WrapperType>
WrapperType getBundleData(const oatpp::String& key) const

# Response::getBundle

Get bundle object.

  • @return

const data::Bundle& getBundle() const

# Response::getBodyStream

Get raw body stream.

std::shared_ptr<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(const base::ObjectHandle<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(const base::ObjectHandle<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 Wrapper>
Wrapper readBodyToDto(const base::ObjectHandle<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::WriteCallback>& writeCallback) const

# Response::transferBodyToStreamAsync

Same as Response::readBodyToDto() but Async.

oatpp::async::CoroutineStarter transferBodyToStreamAsync(const std::shared_ptr<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 Wrapper>
oatpp::async::CoroutineStarterForResult<const Wrapper&>
readBodyToDtoAsync(const std::shared_ptr<data::mapping::ObjectMapper>& objectMapper) const