#include <cl_http_client.hpp>
Definition at line 38 of file cl_http_client.hpp.
◆ TResponse
◆ kHttpRequestMethod
Definition at line 69 of file cl_http_client.hpp.
70 {
71 GET =
static_cast<int>(boost::beast::http::verb::get),
72 POST =
static_cast<int>(boost::beast::http::verb::post),
73 PUT =
static_cast<int>(boost::beast::http::verb::put),
74 };
◆ ClHttp()
cl_http::ClHttp::ClHttp |
( |
const std::string & | server, |
|
|
const int & | timeout = 1500 ) |
|
explicit |
Definition at line 25 of file cl_http_client.cpp.
31{
33 ssl_context_.set_verify_mode(boost::asio::ssl::verify_peer);
34}
boost::asio::io_context io_context_
boost::asio::executor_work_guard< decltype(io_context_)::executor_type > worker_guard_
boost::asio::ssl::context ssl_context_
References ssl_context_.
◆ ~ClHttp()
cl_http::ClHttp::~ClHttp |
( |
| ) |
|
|
virtual |
◆ makeRequest()
void cl_http::ClHttp::makeRequest |
( |
const kHttpRequestMethod | http_method, |
|
|
const std::string & | path = "/", |
|
|
const std::string & | body = "", |
|
|
const std::unordered_map< std::string, std::string > & | headers = {} ) |
Definition at line 51 of file cl_http_client.cpp.
54{
55 auto path_used = path;
56 if (path[0] != '/')
57 {
58 std::reverse(path_used.begin(), path_used.end());
59 path_used += '/';
60 std::reverse(path_used.begin(), path_used.end());
61 }
62
65 RCLCPP_INFO(this->
getLogger(),
"Path %s", path_used.c_str());
67
68 std::shared_ptr<http_session_base> http_session_ptr;
69
71 {
72 http_session_ptr = std::make_shared<ssl_http_session>(
74 }
75 else
76 {
77 http_session_ptr =
79 }
80
81 http_session_ptr->setBody(body);
82 http_session_ptr->setHeaders(headers);
83 http_session_ptr->run(
86}
std::string getServerName() const
std::string getPort() const
std::function< void(TResponse)> callbackHandler
rclcpp::Logger getLogger()
References callbackHandler, smacc2::ISmaccClient::getLogger(), cl_http::ClHttp::Server::getPort(), cl_http::ClHttp::Server::getServerName(), HTTP_VERSION, io_context_, cl_http::ClHttp::Server::isSSL(), server_, and ssl_context_.
Referenced by cl_http::CbHttpRequestBase::onEntry().
◆ onInitialize()
void cl_http::ClHttp::onInitialize |
( |
| ) |
|
|
overridevirtual |
◆ onResponseReceived()
template<typename T >
boost::signals2::connection cl_http::ClHttp::onResponseReceived |
( |
void(T::* | callback )(const TResponse &), |
|
|
T * | object ) |
|
inline |
◆ callbackHandler
std::function<void(TResponse)> cl_http::ClHttp::callbackHandler |
|
private |
◆ HTTP_VERSION
const int cl_http::ClHttp::HTTP_VERSION = 11 |
|
private |
◆ initialized_
bool cl_http::ClHttp::initialized_ |
|
private |
◆ io_context_
boost::asio::io_context cl_http::ClHttp::io_context_ |
|
private |
◆ is_ssl_
bool cl_http::ClHttp::is_ssl_ |
|
private |
◆ onResponseReceived_
◆ server_
Server cl_http::ClHttp::server_ |
|
private |
◆ ssl_context_
boost::asio::ssl::context cl_http::ClHttp::ssl_context_ |
|
private |
◆ tcp_connection_runner_
std::thread cl_http::ClHttp::tcp_connection_runner_ |
|
private |
◆ timeout_
int cl_http::ClHttp::timeout_ |
|
private |
◆ worker_guard_
boost::asio::executor_work_guard<decltype(io_context_)::executor_type> cl_http::ClHttp::worker_guard_ |
|
private |
The documentation for this class was generated from the following files: