61 request->setBodyAsJson(command);
64 }
catch (exception
const& ex) {
65 isc_throw(ControlSocketError,
"failed to create request: "
71 boost::system::error_code received_ec;
72 string receive_errmsg;
76 [&io_service, &received_ec, &receive_errmsg]
77 (
const boost::system::error_code& ec,
81 receive_errmsg = errmsg;
85 io_service->stopWork();
93 io_service->stopAndPoll();
97 isc_throw(ControlSocketError,
"communication error (code): "
98 << received_ec.message());
101 if (!receive_errmsg.empty()) {
103 isc_throw(ControlSocketError,
"communication error (message): "
109 isc_throw(ControlSocketError,
"empty response");
113 return (response->getBodyAsJson());
114 }
catch (exception
const& ex) {
115 isc_throw(ControlSocketError,
"unparsable response: " << ex.what());
The IOService class is a wrapper for the ASIO io_context class.
Represents HTTP response with JSON content.
Represents HTTP POST request with JSON body.
ControlSocketBase(CfgControlSocketPtr ctrl_sock)
Constructor.
const isc::http::Url getUrl() const
Returns the HTTP server URL.
Class for control socket communication over HTTP socket.
data::ConstElementPtr configTest(data::ElementPtr config, const std::string &service) override final
Test configuration.
data::ConstElementPtr configSet(data::ElementPtr config, const std::string &service) override final
Set configuration.
data::ConstElementPtr configGet(const std::string &service) override final
Get configuration.
HttpControlSocket(CfgControlSocketPtr ctrl_sock)
Constructor.
This file contains several functions and constants that are used for handling commands and responses ...
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
Contains declarations for HTTP control socket communication.
boost::shared_ptr< TlsContext > TlsContextPtr
The type of shared pointers to TlsContext objects.
boost::shared_ptr< IOService > IOServicePtr
Defines a smart pointer to an IOService instance.
ConstElementPtr createCommand(const std::string &command)
Creates a standard command message with no argument (of the form { "command": "my_command" }...
constexpr long TIMEOUT_DHCP_SERVER_FORWARD_COMMAND
Timeout for the DHCP server to forward command to a Kea server, e.g.
boost::shared_ptr< const Element > ConstElementPtr
boost::shared_ptr< Element > ElementPtr
boost::shared_ptr< PostHttpRequestJson > PostHttpRequestJsonPtr
Pointer to PostHttpRequestJson.
boost::shared_ptr< HttpResponseJson > HttpResponseJsonPtr
Pointer to the HttpResponseJson object.
boost::shared_ptr< HttpResponse > HttpResponsePtr
Pointer to the HttpResponse object.
std::shared_ptr< HttpControlSocket > HttpControlSocketPtr
Type definition for the pointer to the HttpControlSocket.
std::shared_ptr< ControlSocketBase > ControlSocketBasePtr
Type definition for the pointer to the ControlSocketBase.
ControlSocketBasePtr createControlSocket< CfgControlSocket::Type::HTTP >(CfgControlSocketPtr ctrl_sock)
Factory template specialization for http control sockets.
std::shared_ptr< CfgControlSocket > CfgControlSocketPtr
Defines a pointer for CfgControlSocket instances.
Defines the logger used by the top-level component of kea-lfc.