SMACC2
Loading...
Searching...
No Matches
cl_http.hpp
Go to the documentation of this file.
1// Copyright 2023 RobosoftAI Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15/*****************************************************************************************************************
16 *
17 * Authors: Jaycee Lock & Brett Aldrich
18 *
19 * Description: HTTP/HTTPS Client using pure component-based architecture
20 *
21 * Architecture:
22 * ClHttp (minimal orchestrator) creates and configures three components:
23 * - CpHttpConnectionManager: io_context and thread management
24 * - CpHttpSessionManager: SSL context and session creation
25 * - CpHttpRequestExecutor: Request execution and response signals
26 *
27 * Usage:
28 * Behaviors should access CpHttpRequestExecutor component directly via requiresComponent()
29 * and connect to its onResponseReceived_ signal for HTTP responses.
30 *
31 * See README.md for complete documentation and examples.
32 *
33 ******************************************************************************************************************/
34
35#pragma once
36
42#include <string>
43
44namespace cl_http
45{
62{
63public:
65
66 explicit ClHttp(const std::string & server, const int & timeout = 1500);
67
68 virtual ~ClHttp();
69
70 void onInitialize() override;
71
72 // Component composition during orthogonal initialization
73 template <typename TOrthogonal, typename TClient>
87
88private:
89 const int HTTP_VERSION = 11;
90
92
93 std::string server_url_; // Server URL for component configuration
94
95 // Component references
99};
100} // namespace cl_http
HTTP/HTTPS client with pure component-based architecture.
Definition cl_http.hpp:62
ClHttp(const std::string &server, const int &timeout=1500)
Definition cl_http.cpp:25
http_session_base::TResponse TResponse
Definition cl_http.hpp:64
CpHttpRequestExecutor * requestExecutor_
Definition cl_http.hpp:98
std::string server_url_
Definition cl_http.hpp:93
void onInitialize() override
Definition cl_http.cpp:40
CpHttpConnectionManager * connectionManager_
Definition cl_http.hpp:96
void onComponentInitialization()
Definition cl_http.hpp:74
const int HTTP_VERSION
Definition cl_http.hpp:89
virtual ~ClHttp()
Definition cl_http.cpp:35
CpHttpSessionManager * sessionManager_
Definition cl_http.hpp:97
void setDependencies(CpHttpConnectionManager *connMgr, CpHttpSessionManager *sessMgr)
void setServerUrl(const std::string &server_url)
boost::beast::http::response< boost::beast::http::string_body > TResponse
SmaccComponentType * createComponent(TArgs... targs)