# Response.hpp

This File On Github
Ask A Question

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

# Response

Class which stores information of outgoing http Response.

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

# Typedefs

Type Name Summary
http::Headers Headers Convenience typedef for Headers.
See oatpp::web::protocol::http::Headers
oatpp::network::ConnectionHandler ConnectionHandler Convenience typedef for oatpp::network::ConnectionHandler.

# Methods

Return Type Name Summary
[none] Response Constructor.
std::shared_ptr<Response> createShared Create shared outgoing response with status and body.
const Status& getStatus Get status.
Headers& getHeaders Get headers.
std::shared_ptr<Body> getBody Get body
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.
void setConnectionUpgradeHandler Set connection upgreade header.
std::shared_ptr<ConnectionHandler> getConnectionUpgradeHandler Get currently set connection upgrade handler.
void setConnectionUpgradeParameters Set connection upgrade parameters.
std::shared_ptr<const ConnectionHandler::ParameterMap> getConnectionUpgradeParameters Get connection upgrade parameters.
void send Write this Response to stream.
oatpp::async::CoroutineStarter sendAsync Same as Response::send() but async.

# Response::Headers

Convenience typedef for Headers.
See oatpp::web::protocol::http::Headers

typedef http::Headers Headers

# Response::ConnectionHandler

Convenience typedef for oatpp::network::ConnectionHandler.

typedef oatpp::network::ConnectionHandler ConnectionHandler

# Response::Response

Constructor.

  • @param status - http status.
  • @param body - response body.

Response(const Status& status, const std::shared_ptr<Body>& body)

# Response::createShared

Create shared outgoing response with status and body.

  • @param status - http status.
  • @param body - response body.
  • @return

static std::shared_ptr<Response> createShared(const Status& status, const std::shared_ptr<Body>& body)

# Response::getStatus

Get status.

  • @return - http status.

const Status& getStatus() const

# Response::getHeaders

Get headers.

Headers& getHeaders()

# Response::getBody

Get body

std::shared_ptr<Body> getBody() 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::setConnectionUpgradeHandler

Set connection upgreade header.
Use it together with corresponding headers being set when Response is created as:
Response(oatpp::web::protocol::http::Status::CODE_101, nullptr);

void setConnectionUpgradeHandler(const std::shared_ptr<ConnectionHandler>& handler)

# Response::getConnectionUpgradeHandler

Get currently set connection upgrade handler.

std::shared_ptr<ConnectionHandler> getConnectionUpgradeHandler()

# Response::setConnectionUpgradeParameters

Set connection upgrade parameters.
Use it to set additional parameters for upgraded connection handling. See Response::setConnectionUpgradeHandler().

void setConnectionUpgradeParameters(const std::shared_ptr<const ConnectionHandler::ParameterMap>& parameters)

# Response::getConnectionUpgradeParameters

Get connection upgrade parameters.

  • @return - std::shared_ptr to const oatpp::network::ConnectionHandler::ParametersMap.

std::shared_ptr<const ConnectionHandler::ParameterMap> getConnectionUpgradeParameters()

# Response::send

Write this Response to stream.

void send(data::stream::OutputStream* stream,
          data::stream::BufferOutputStream* headersWriteBuffer,
          http::encoding::EncoderProvider* contentEncoderProvider)

# Response::sendAsync

Same as Response::send() but async.

static oatpp::async::CoroutineStarter sendAsync(const std::shared_ptr<Response>& _this,
                                                const std::shared_ptr<data::stream::OutputStream>& stream,
                                                const std::shared_ptr<data::stream::BufferOutputStream>& headersWriteBuffer,
                                                const std::shared_ptr<http::encoding::EncoderProvider>& contentEncoderProvider)