RequestExecutor.hpp

This File On Github
Ask A Question

API: latest
module: oatpp-curl
#include "oatpp-curl/RequestExecutor.hpp"

RequestExecutor

Curl request executor. Uses Curl to perform client to server requests.
Extends oatpp::web::client::RequestExecutor.

namespace oatpp { namespace curl { 
  class RequestExecutor : public oatpp::web::client::RequestExecutor {}
}}

Methods

Return Type Name Summary
[none] RequestExecutor Constructor.
std::shared_ptr<RequestExecutor> createShared Create shared RequestExecutor.
std::shared_ptr<ConnectionHandle> getConnection Connection reuse mechanism for curl RequestExecutor is NOT IMPLEMENTED yet.
oatpp::async::CoroutineStarterForResult<const std::shared_ptr<ConnectionHandle>&> getConnectionAsync Connection reuse mechanism for curl RequestExecutor is NOT IMPLEMENTED yet.
void invalidateConnection Invalidate connection.
std::shared_ptr<Response> executeOnce Execute http request. Implementation of oatpp::curl::RequestExecutor::execute method.
oatpp::async::CoroutineStarterForResult<const std::shared_ptr<Response>&> executeOnceAsync Same as RequestExecutor::execute() but Async.

RequestExecutor::RequestExecutor

Constructor.

  • @param baseUrl - base url for requests. Ex.: "https://oatpp.io/"
  • @param verbose - true to print curl logs to std::cout.

RequestExecutor(const oatpp::String& baseUrl, bool verbose = false)

RequestExecutor::createShared

Create shared RequestExecutor.

  • @param baseUrl - base url for requests. Ex.: "https://oatpp.io/"
  • @param verbose - true to print curl logs to std::cout.
  • @return - std::shared_ptr to RequestExecutor.

static std::shared_ptr<RequestExecutor> createShared(const oatpp::String& baseUrl, bool verbose = false)

RequestExecutor::getConnection

Connection reuse mechanism for curl RequestExecutor is NOT IMPLEMENTED yet.

std::shared_ptr<ConnectionHandle> getConnection() override

RequestExecutor::getConnectionAsync

Connection reuse mechanism for curl RequestExecutor is NOT IMPLEMENTED yet.

oatpp::async::CoroutineStarterForResult<const std::shared_ptr<ConnectionHandle>&> getConnectionAsync() override

RequestExecutor::invalidateConnection

Invalidate connection.

  • @param connectionHandle

void invalidateConnection(const std::shared_ptr<ConnectionHandle>& connectionHandle) override

RequestExecutor::executeOnce

Execute http request. Implementation of oatpp::curl::RequestExecutor::execute method.

std::shared_ptr<Response> executeOnce(const String& method,
                                      const String& path,
                                      const Headers& userDefinedHeaders,
                                      const std::shared_ptr<Body>& body,
                                      const std::shared_ptr<ConnectionHandle>& connectionHandle = nullptr) override

RequestExecutor::executeOnceAsync

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 - nullptr. This parameter is ignored for now.
  • @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 = nullptr) override

RequestExecutor::StubConnectionHandle

Connection reuse mechanism for curl RequestExecutor is NOT IMPLEMENTED yet.
Use dummy stub to mock the real connection and prevent the crash.

namespace oatpp { namespace curl { 
  class RequestExecutor : public oatpp::web::client::RequestExecutor {
    class StubConnectionHandle : public ConnectionHandle {}
  };
}}