# Request.hpp
This File On Github
Ask A Question
API: latest
module: oatpp
#include "oatpp/web/protocol/http/outgoing/Request.hpp"
# Request
Class http::outgoing::Request AKA OutgoingRequest represents client's outgoing request to server.
namespace oatpp { namespace web { namespace protocol { namespace http { namespace outgoing {
class Request : public oatpp::base::Countable {}
}}}}}
# Typedefs
Type | Name | Summary |
---|---|---|
protocol::http::Headers | Headers | Convenience typedef for oatpp::web::protocol::http::Headers. |
# Methods
Return Type | Name | Summary |
---|---|---|
[none] | Request | Constructor. |
std::shared_ptr<Request> | createShared | Create shared Request. |
const oatpp::data::share::StringKeyLabel& | getMethod | Get http method. |
const oatpp::data::share::StringKeyLabel& | getPath | Get path to resource. |
Headers& | getHeaders | Get headers map. |
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<Body> | getBody | Get http body. |
void | send | Write request to stream. |
oatpp::async::CoroutineStarter | sendAsync | Write request to stream in asynchronous manner. |
# Request::Headers
Convenience typedef for oatpp::web::protocol::http::Headers.
typedef protocol::http::Headers Headers
# Request::Request
Constructor.
- @param method - http method. oatpp::data::share::StringKeyLabel.
- @param path - path to resource. oatpp::data::share::StringKeyLabel.
- @param headers - Request::Headers.
- @param body -
std::shared_ptr
to oatpp::web::protocol::http::outgoing::Body.
Request(const oatpp::data::share::StringKeyLabel& method,
const oatpp::data::share::StringKeyLabel& path,
const Headers& headers,
const std::shared_ptr<Body>& body)
# Request::createShared
Create shared Request.
- @param method - http method. oatpp::data::share::StringKeyLabel.
- @param path - path to resource. oatpp::data::share::StringKeyLabel.
- @param headers - Request::Headers.
- @param body -
std::shared_ptr
to oatpp::web::protocol::http::outgoing::Body. - @return -
std::shared_ptr
to Request.
static std::shared_ptr<Request> createShared(const oatpp::data::share::StringKeyLabel& method,
const oatpp::data::share::StringKeyLabel& path,
const Headers& headers,
const std::shared_ptr<Body>& body)
# Request::getMethod
Get http method.
- @return - http method. oatpp::data::share::StringKeyLabel.
const oatpp::data::share::StringKeyLabel& getMethod() const
# Request::getPath
Get path to resource.
- @return - path to resource. oatpp::data::share::StringKeyLabel.
const oatpp::data::share::StringKeyLabel& getPath() const
# Request::getHeaders
Get headers map.
- @return - Request::Headers.
Headers& getHeaders()
# Request::putHeader
Add http header.
- @param key - oatpp::String.
- @param value - oatpp::String.
void putHeader(const oatpp::String& key, const oatpp::String& value)
# Request::putHeaderIfNotExists
Add http header if not already exists.
- @param key - oatpp::String.
- @param value - oatpp::String.
- @return -
true
if header was added.
bool putHeaderIfNotExists(const oatpp::String& key, const oatpp::String& value)
# Request::putOrReplaceHeader
Replaces or adds header.
- @param key - oatpp::String.
- @param value - oatpp::String.
- @return -
true
if header was replaces,false
if header was added.
bool putOrReplaceHeader(const oatpp::String& key, const oatpp::String& value)
# Request::putOrReplaceHeader_Unsafe
Replaces or adds header.
- @param key - oatpp::data::share::StringKeyLabelCI.
- @param value - oatpp::data::share::StringKeyLabel.
- @return -
true
if header was replaces,false
if header was added.
bool putOrReplaceHeader_Unsafe(const oatpp::data::share::StringKeyLabelCI& key, const oatpp::data::share::StringKeyLabel& value)
# Request::putHeader_Unsafe
Add http header.
- @param key - oatpp::data::share::StringKeyLabelCI.
- @param value - oatpp::data::share::StringKeyLabel.
void putHeader_Unsafe(const oatpp::data::share::StringKeyLabelCI& key, const oatpp::data::share::StringKeyLabel& value)
# Request::putHeaderIfNotExists_Unsafe
Add http header if not already exists.
- @param key - oatpp::data::share::StringKeyLabelCI.
- @param value - oatpp::data::share::StringKeyLabel.
- @return -
true
if header was added.
bool putHeaderIfNotExists_Unsafe(const oatpp::data::share::StringKeyLabelCI& key, const oatpp::data::share::StringKeyLabel& value)
# Request::getHeader
Get header value
- @param headerName - oatpp::data::share::StringKeyLabelCI.
- @return - oatpp::String.
oatpp::String getHeader(const oatpp::data::share::StringKeyLabelCI& headerName) const
# Request::putBundleData
Put data to bundle.
- @param key
- @param polymorph
void putBundleData(const oatpp::String& key, const oatpp::Void& polymorph)
# Request::getBundleData
Get data from bundle by key.
- @tparam WrapperType
- @param key
- @return
template<typename WrapperType>
WrapperType getBundleData(const oatpp::String& key) const
# Request::getBundle
Get bundle object.
- @return
const data::Bundle& getBundle() const
# Request::getBody
Get http body.
- @return - oatpp::web::protocol::http::outgoing::Body.
std::shared_ptr<Body> getBody()
# Request::send
Write request to stream.
- @param stream - oatpp::data::stream::OutputStream.
void send(data::stream::OutputStream* stream)
# Request::sendAsync
Write request to stream in asynchronous manner.
- @param _this
- @param stream - oatpp::data::stream::OutputStream.
- @return - oatpp::async::CoroutineStarter.
static oatpp::async::CoroutineStarter sendAsync(std::shared_ptr<Request> _this,
const std::shared_ptr<data::stream::OutputStream>& stream)