# RequestExecutor.hpp
This File On Github
Ask A Question
API: latest
module: oatpp
#include "oatpp/web/client/RequestExecutor.hpp"
# RequestExecutor
Abstract RequestExecutor. RequestExecutor is class responsible for making remote requests.
namespace oatpp { namespace web { namespace client {
class RequestExecutor {}
}}}
# Typedefs
Type | Name | Summary |
---|---|---|
oatpp::String | String | Convenience typedef for oatpp::String. |
oatpp::async::Action | Action | Convenience typedef for oatpp::async::Action. |
oatpp::web::protocol::http::Headers | Headers | Convenience typedef for oatpp::web::protocol::http::Headers. |
oatpp::web::protocol::http::incoming::Response | Response | Convenience typedef for oatpp::web::protocol::http::incoming::Response. |
oatpp::web::protocol::http::outgoing::Body | Body | Convenience typedef for oatpp::web::protocol::http::outgoing::Body. |
# Methods
Return Type | Name | Summary |
---|---|---|
[none] | RequestExecutor | Constructor. |
[none] | ~RequestExecutor | Virtual destructor. |
std::shared_ptr<ConnectionHandle> | getConnection | Obtain RequestExecutor::ConnectionHandle which then can be passed to RequestExecutor::execute(). |
oatpp::async::CoroutineStarterForResult<const std::shared_ptr<ConnectionHandle>&> | getConnectionAsync | Same as RequestExecutor::getConnection() but Async. |
void | invalidateConnection | Invalidate connection. |
std::shared_ptr<Response> | executeOnce | Execute request once without any retries. |
oatpp::async::CoroutineStarterForResult<const std::shared_ptr<Response>&> | executeOnceAsync | Same as RequestExecutor::executeOnce() but Async. |
std::shared_ptr<Response> | execute | Execute request taking into account retry policy. |
oatpp::async::CoroutineStarterForResult<const std::shared_ptr<Response>&> | executeAsync | Same as RequestExecutor::execute() but Async. |
# RequestExecutor::String
Convenience typedef for oatpp::String.
typedef oatpp::String String
# RequestExecutor::Action
Convenience typedef for oatpp::async::Action.
typedef oatpp::async::Action Action
# RequestExecutor::Headers
Convenience typedef for oatpp::web::protocol::http::Headers.
typedef oatpp::web::protocol::http::Headers Headers
# RequestExecutor::Response
Convenience typedef for oatpp::web::protocol::http::incoming::Response.
typedef oatpp::web::protocol::http::incoming::Response Response
# RequestExecutor::Body
Convenience typedef for oatpp::web::protocol::http::outgoing::Body.
typedef oatpp::web::protocol::http::outgoing::Body Body
# RequestExecutor::RequestExecutor
Constructor.
- @param retryPolicy - oatpp::web::client::RetryPolicy.
RequestExecutor(const std::shared_ptr<RetryPolicy>& retryPolicy)
# RequestExecutor::~RequestExecutor
Virtual destructor.
virtual ~RequestExecutor() = default
# RequestExecutor::getConnection
Obtain RequestExecutor::ConnectionHandle which then can be passed to RequestExecutor::execute().
- @return std::shared_ptr to RequestExecutor::ConnectionHandle.
virtual std::shared_ptr<ConnectionHandle> getConnection() = 0
# RequestExecutor::getConnectionAsync
Same as RequestExecutor::getConnection() but Async.
- @return - oatpp::async::CoroutineStarterForResult.
virtual oatpp::async::CoroutineStarterForResult<const std::shared_ptr<ConnectionHandle>&> getConnectionAsync() = 0
# RequestExecutor::invalidateConnection
Invalidate connection.
- @param connectionHandle
virtual void invalidateConnection(const std::shared_ptr<ConnectionHandle>& connectionHandle) = 0
# RequestExecutor::executeOnce
Execute request once without any retries.
- @param method - method ex: ["GET", "POST", "PUT", etc.].
- @param path - path to resource.
- @param headers - headers map RequestExecutor::Headers.
- @param body -
std::shared_ptr
to RequestExecutor::Body object. - @param connectionHandle - RequestExecutor::ConnectionHandle
- @return - oatpp::web::protocol::http::incoming::Response.
virtual std::shared_ptr<Response> executeOnce(const String& method,
const String& path,
const Headers& headers,
const std::shared_ptr<Body>& body,
const std::shared_ptr<ConnectionHandle>& connectionHandle) = 0
# RequestExecutor::executeOnceAsync
Same as RequestExecutor::executeOnce() but Async.
- @param method - method ex: ["GET", "POST", "PUT", etc.].
- @param path - path to resource.
- @param headers - headers map RequestExecutor::Headers.
- @param body -
std::shared_ptr
to RequestExecutor::Body object. - @param connectionHandle - RequestExecutor::ConnectionHandle.
- @return - oatpp::async::CoroutineStarterForResult.
virtual oatpp::async::CoroutineStarterForResult<const std::shared_ptr<Response>&>
executeOnceAsync(const String& method,
const String& path,
const Headers& headers,
const std::shared_ptr<Body>& body,
const std::shared_ptr<ConnectionHandle>& connectionHandle) = 0
# RequestExecutor::execute
Execute request taking into account retry policy.
- @param method - method ex: ["GET", "POST", "PUT", etc.].
- @param path - path to resource.
- @param headers - headers map RequestExecutor::Headers.
- @param body -
std::shared_ptr
to RequestExecutor::Body object. - @param connectionHandle - RequestExecutor::ConnectionHandle
- @return - oatpp::web::protocol::http::incoming::Response.
virtual std::shared_ptr<Response> execute(const String& method,
const String& path,
const Headers& headers,
const std::shared_ptr<Body>& body,
const std::shared_ptr<ConnectionHandle>& connectionHandle)
# RequestExecutor::executeAsync
Same as RequestExecutor::execute() but Async.
- @param method - method ex: ["GET", "POST", "PUT", etc.].
- @param path - path to resource.
- @param headers - headers map RequestExecutor::Headers.
- @param body -
std::shared_ptr
to RequestExecutor::Body object. - @param connectionHandle - RequestExecutor::ConnectionHandle.
- @return - oatpp::async::CoroutineStarterForResult.
oatpp::async::CoroutineStarterForResult<const std::shared_ptr<Response>&>
virtual executeAsync(const String& method,
const String& path,
const Headers& headers,
const std::shared_ptr<Body>& body,
const std::shared_ptr<ConnectionHandle>& connectionHandle)
# RequestExecutor::ConnectionHandle
ConnectionHandle is always specific to a RequestExecutor. You can't pass ConnectionHandle retrieved by one RequestExecutor implementation to another
namespace oatpp { namespace web { namespace client {
class RequestExecutor {
class ConnectionHandle {}
};
}}}
# RequestExecutor::RequestExecutionError
Class representing Request Execution Error.
namespace oatpp { namespace web { namespace client {
class RequestExecutor {
class RequestExecutionError : public std::runtime_error {}
};
}}}
# Fields
Type | Name | Summary |
---|---|---|
const v_int32 | ERROR_CODE_CANT_CONNECT | Error code for "can't connect" error. |
const v_int32 | ERROR_CODE_CANT_PARSE_STARTING_LINE | Error code for "can't parse starting line" error. |
const v_int32 | ERROR_CODE_CANT_PARSE_HEADERS | Error code for "can't parse headers" error. |
const v_int32 | ERROR_CODE_CANT_READ_RESPONSE | Error code for "can't read response" error. |
const v_int32 | ERROR_CODE_NO_RESPONSE | Error code for "no response" error. |
# Methods
Return Type | Name | Summary |
---|---|---|
[none] | RequestExecutionError | Constructor. |
v_int32 | getErrorCode | Get error code. |
const char* | getMessage | Get error message. |
v_int32 | getReadErrorCode | This value is valid if errorCode == RequestExecutor::RequestExecutionError::ERROR_CODE_CANT_READ_RESPONSE |
# RequestExecutor::RequestExecutionError::ERROR_CODE_CANT_CONNECT
Error code for "can't connect" error.
constexpr static const v_int32 ERROR_CODE_CANT_CONNECT = 1
# RequestExecutor::RequestExecutionError::ERROR_CODE_CANT_PARSE_STARTING_LINE
Error code for "can't parse starting line" error.
constexpr static const v_int32 ERROR_CODE_CANT_PARSE_STARTING_LINE = 2
# RequestExecutor::RequestExecutionError::ERROR_CODE_CANT_PARSE_HEADERS
Error code for "can't parse headers" error.
constexpr static const v_int32 ERROR_CODE_CANT_PARSE_HEADERS = 3
# RequestExecutor::RequestExecutionError::ERROR_CODE_CANT_READ_RESPONSE
Error code for "can't read response" error.
constexpr static const v_int32 ERROR_CODE_CANT_READ_RESPONSE = 4
# RequestExecutor::RequestExecutionError::ERROR_CODE_NO_RESPONSE
Error code for "no response" error.
constexpr static const v_int32 ERROR_CODE_NO_RESPONSE = 5
# RequestExecutor::RequestExecutionError::RequestExecutionError
Constructor.
- @param errorCode - error code.
- @param message - error message.
- @param readErrorCode - io error code.
RequestExecutionError(v_int32 errorCode, const char* message, v_int32 readErrorCode = 0)
# RequestExecutor::RequestExecutionError::getErrorCode
Get error code.
- @return - error code.
v_int32 getErrorCode() const
# RequestExecutor::RequestExecutionError::getMessage
Get error message.
- @return - error message.
const char* getMessage() const
# RequestExecutor::RequestExecutionError::getReadErrorCode
This value is valid if errorCode == RequestExecutor::RequestExecutionError::ERROR_CODE_CANT_READ_RESPONSE
For more information about the read error you get check out:
- oatpp::data::stream::IOStream for possible error codes.
- Implementation-specific behaviour of corresponding Connection and ConnectionProvider.
v_int32 getReadErrorCode() const