17#include <boost/pointer_cast.hpp>
29struct HttpCommandHooks {
30 int hook_index_http_auth_;
31 int hook_index_http_response_;
60 HttpResponsePtr response = createStockHttpResponseInternal(request, status_code);
66HttpCommandResponseCreator::
73 HttpVersion http_version(request->context()->http_version_major_,
74 request->context()->http_version_minor_);
78 http_version.major_ = 1;
79 http_version.minor_ = 0;
87HttpCommandResponseCreator::createDynamicHttpResponse(
HttpRequestPtr request) {
94 http_response = auth->checkAuth(*
this, request);
99 bool reset_handle =
false;
106 callout_handle->setArgument(
"request", request);
107 callout_handle->setArgument(
"response", http_response);
112 callout_handle->getArgument(
"request", request);
113 callout_handle->getArgument(
"response", http_response);
124 return (http_response);
129 request->resetCalloutHandle();
139 boost::dynamic_pointer_cast<PostHttpRequestJson>(request);
163 if ((!config_ || config_->getEmulateAgentResponse()) &&
166 response_list->add(boost::const_pointer_cast<Element>(response));
167 response = response_list;
171 http_response = boost::dynamic_pointer_cast<
172 HttpResponseJson>(createStockHttpResponseInternal(request, HttpStatusCode::OK));
174 http_response->finalize();
183 callout_handle->setArgument(
"request", request);
184 callout_handle->setArgument(
"response", http_response);
189 callout_handle->getArgument(
"response", http_response);
194 return (http_response);
static CommandMgr & instance()
CommandMgr is a singleton class.
virtual http::HttpRequestPtr createNewHttpRequest() const
Create a new request.
virtual http::HttpResponsePtr createStockHttpResponse(const http::HttpRequestPtr &request, const http::HttpStatusCode &status_code) const
Creates stock HTTP response.
static ElementPtr createList(const Position &pos=ZERO_POSITION())
Creates an empty ListElement type ElementPtr.
@ 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< const Element > ConstElementPtr
boost::shared_ptr< Element > ElementPtr
boost::shared_ptr< CalloutHandle > CalloutHandlePtr
A shared pointer to a CalloutHandle object.
HttpStatusCode
HTTP status codes (cf RFC 2068)
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.
Defines the logger used by the top-level component of kea-lfc.