20#include <boost/pointer_cast.hpp>
30struct CtrlAgentHooks {
31 int hook_index_http_auth_;
32 int hook_index_http_response_;
61 HttpResponsePtr response = createStockHttpResponseInternal(request, status_code);
75 boost::shared_ptr<CtrlAgentController> controller =
82 ctx = cfgmgr->getCtrlAgentCfgContext();
92CtrlAgentResponseCreator::
99 HttpVersion http_version(request->context()->http_version_major_,
100 request->context()->http_version_minor_);
104 http_version.major_ = 1;
105 http_version.minor_ = 0;
117CtrlAgentResponseCreator::
128 headers = ctx->getHttpHeaders();
132 http_response = auth->checkAuth(*
this, request);
137 bool auth_failed =
false;
144 bool reset_handle =
false;
151 callout_handle->setArgument(
"request", request);
152 callout_handle->setArgument(
"response", http_response);
157 callout_handle->getArgument(
"request", request);
158 callout_handle->getArgument(
"response", http_response);
170 if (!auth_failed && !headers.empty()) {
172 if (http_response->isFinalized()) {
174 http_response->reset();
175 http_response->finalize();
178 return (http_response);
183 request->resetCalloutHandle();
193 boost::dynamic_pointer_cast<PostHttpRequestJson>(request);
212 http_response = boost::dynamic_pointer_cast<
213 HttpResponseJson>(createStockHttpResponseInternal(request, HttpStatusCode::OK));
215 http_response->finalize();
224 callout_handle->setArgument(
"request", request);
225 callout_handle->setArgument(
"response", http_response);
230 callout_handle->getArgument(
"response", http_response);
235 return (http_response);
static CtrlAgentCommandMgr & instance()
Returns sole instance of the Command Manager.
virtual isc::data::ConstElementPtr processCommand(const isc::data::ConstElementPtr &cmd)
Triggers command processing.
static process::DControllerBasePtr & instance()
Static singleton instance method.
virtual http::HttpResponsePtr createStockHttpResponse(const http::HttpRequestPtr &request, const http::HttpStatusCode &status_code) const
Creates stock HTTP response.
virtual http::HttpRequestPtr createNewHttpRequest() const
Create a new request.
@ NEXT_STEP_CONTINUE
continue normally
static int registerHook(const std::string &name)
Register Hook.
static bool calloutsPresent(int index)
Are callouts present?
static void callCallouts(int index, CalloutHandle &handle)
Calls the callouts for a given hook.
Wrapper class around callout handle which automatically resets handle's state.
Represents HTTP response with JSON content.
void setBodyAsJson(const data::ConstElementPtr &json_body)
Generates JSON content from the data structures represented as data::ConstElementPtr.
Represents HTTP POST request with JSON body.
boost::shared_ptr< CtrlAgentCfgContext > CtrlAgentCfgContextPtr
Pointer to a configuration context.
boost::shared_ptr< CtrlAgentProcess > CtrlAgentProcessPtr
Defines a shared pointer to CtrlAgentProcess.
boost::shared_ptr< CtrlAgentCfgMgr > CtrlAgentCfgMgrPtr
Defines a shared pointer to CtrlAgentCfgMgr.
boost::shared_ptr< const Element > ConstElementPtr
boost::shared_ptr< CalloutHandle > CalloutHandlePtr
A shared pointer to a CalloutHandle object.
HttpStatusCode
HTTP status codes (cf RFC 2068)
void copyHttpHeaders(const CfgHttpHeaders &headers, const HTTP_MSG &message)
Copy config HTTP headers to message.
boost::shared_ptr< PostHttpRequestJson > PostHttpRequestJsonPtr
Pointer to PostHttpRequestJson.
boost::shared_ptr< HttpAuthConfig > HttpAuthConfigPtr
Type of shared pointers to HTTP authentication configuration.
boost::shared_ptr< HttpResponseJson > HttpResponseJsonPtr
Pointer to the HttpResponseJson object.
boost::shared_ptr< HttpResponse > HttpResponsePtr
Pointer to the HttpResponse object.
boost::shared_ptr< HttpRequest > HttpRequestPtr
Pointer to the HttpRequest object.
std::vector< CfgHttpHeader > CfgHttpHeaders
Collection of config HTTP headers.
Defines the logger used by the top-level component of kea-lfc.