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, public std::enable_shared_from_this<Response> {}
}}}}}

Typedefs

Type Name Summary
http::Headers Headers Convenience typedef for Headers.
See oatpp::web::protocol::http::Headers
oatpp::network::server::ConnectionHandler ConnectionHandler Convenience typedef for oatpp::network::server::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.
void putHeader Add http header.
bool putHeaderIfNotExists Add http header if not already exists.
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::server::ConnectionHandler.

typedef oatpp::network::server::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::putHeader

Add http header.

void putHeader(const oatpp::data::share::StringKeyLabelCI_FAST& key, const oatpp::data::share::StringKeyLabel& value)

Response::putHeaderIfNotExists

Add http header if not already exists.

bool putHeaderIfNotExists(const oatpp::data::share::StringKeyLabelCI_FAST& key, const oatpp::data::share::StringKeyLabel& value)

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::server::ConnectionHandler::ParametersMap.

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

Response::send

Write this Response to stream.

void send(const std::shared_ptr<data::stream::OutputStream>& stream)

Response::sendAsync

Same as Response::send() but async.

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