Kea  1.9.9-git
isc::http::HttpResponseCreator Class Referenceabstract

Specifies an interface for classes creating HTTP responses from HTTP requests. More...

#include <response_creator.h>

+ Inheritance diagram for isc::http::HttpResponseCreator:

Public Member Functions

virtual ~HttpResponseCreator ()
 Destructor. More...
 
virtual HttpResponsePtr createHttpResponse (HttpRequestPtr request) final
 Create HTTP response from HTTP request received. More...
 
virtual HttpRequestPtr createNewHttpRequest () const =0
 Create a new request. More...
 
virtual HttpResponsePtr createStockHttpResponse (const HttpRequestPtr &request, const HttpStatusCode &status_code) const =0
 Creates implementation specific HTTP response. More...
 

Protected Member Functions

virtual HttpResponsePtr createDynamicHttpResponse (HttpRequestPtr request)=0
 Creates implementation specific HTTP response. More...
 

Detailed Description

Specifies an interface for classes creating HTTP responses from HTTP requests.

HTTP is designed to carry various content types. Most commonly this is text/html. In Kea, the application/json content type is used to carry control commands in JSON format. The libkea-http library is meant to be generic and provide means for transferring different types of content, depending on the use case.

This abstract class specifies a common interface for generating HTTP responses from HTTP requests using specific content type and being used in some specific context. Kea modules providing HTTP services need to implement their specific derivations of the HttpResponseCreator class. These derivations use classes derived from HttpRequest as an input and classes derived from HttpResponse as an output of createHttpResponse method.

Definition at line 38 of file response_creator.h.

Constructor & Destructor Documentation

virtual isc::http::HttpResponseCreator::~HttpResponseCreator ( )
inlinevirtual

Destructor.

Classes with virtual functions need virtual destructors.

Definition at line 44 of file response_creator.h.

Member Function Documentation

virtual HttpResponsePtr isc::http::HttpResponseCreator::createDynamicHttpResponse ( HttpRequestPtr  request)
protectedpure virtual

Creates implementation specific HTTP response.

Parameters
requestPointer to an object representing HTTP request.
Returns
Pointer to an object representing HTTP response.

Referenced by createHttpResponse().

HttpResponsePtr isc::http::HttpResponseCreator::createHttpResponse ( HttpRequestPtr  request)
finalvirtual

Create HTTP response from HTTP request received.

This class implements a generic logic for creating a HTTP response. Derived classes do not override this method. They merely implement the methods it calls.

The request processing may generally fail at one of the two stages: parsing or interpretation of the parsed request. During the former stage the request's syntax is checked, i.e. HTTP version, URI, headers etc. During the latter stage the HTTP server checks if the request is valid within the specific context, e.g. valid HTTP version used, expected content type etc.

In the HttpRequest terms, the request has gone through the first stage if it is "finalized" (see HttpRequest::finalize). This method accepts instances of both finalized and not finalized requests. If the request isn't finalized it indicates that the request parsing has failed. In such case, this method calls createStockBadRequest to generate a response with HTTP 400 status code. If the request is finalized, this method calls createDynamicHttpResponse to generate implementation specific response to the received request.

This method is marked virtual final to prevent derived classes from overriding this method. Instead, the derived classes must implement protected methods which this method calls.

Parameters
requestPointer to an object representing HTTP request.
Returns
Pointer to the object encapsulating generated HTTP response.
Exceptions
HttpResponseErrorif request is a NULL pointer.

Definition at line 15 of file response_creator.cc.

References isc::http::BAD_REQUEST, createDynamicHttpResponse(), createStockHttpResponse(), and isc_throw.

+ Here is the call graph for this function:

virtual HttpRequestPtr isc::http::HttpResponseCreator::createNewHttpRequest ( ) const
pure virtual

Create a new request.

This method creates an instance of the HttpRequest or derived class. The type of the object is compatible with the instance of the HttpResponseCreator implementation which creates it, i.e. can be used as an argument in the call to createHttpResponse.

Returns
Pointer to the new instance of the HttpRequest.

Implemented in isc::config::CmdResponseCreator, and isc::agent::CtrlAgentResponseCreator.

virtual HttpResponsePtr isc::http::HttpResponseCreator::createStockHttpResponse ( const HttpRequestPtr request,
const HttpStatusCode status_code 
) const
pure virtual

Creates implementation specific HTTP response.

Parameters
requestPointer to an object representing HTTP request.
status_codeStatus code of the response.
Returns
Pointer to an object representing HTTP response.

Implemented in isc::config::CmdResponseCreator, and isc::agent::CtrlAgentResponseCreator.

Referenced by isc::http::BasicHttpAuthConfig::checkAuth(), and createHttpResponse().


The documentation for this class was generated from the following files: