Kea: response_creator.cc Source File

| Kea 3.2.0-git

response_creator.cc
Go to the documentation of this file.
1// Copyright (C) 2016-2020 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#include <config.h>
8
9#include <http/response_creator.h>
10
11namespace isc {
12namespace http {
13
14 HttpResponsePtr
15HttpResponseCreator::createHttpResponse(HttpRequestPtr request) {
16 // This should never happen. This method must only be called with a
17 // non null request, so we consider it unlikely internal server error.
18 if (!request) {
19 isc_throw(HttpResponseError, "internal server error: HTTP request is null");
20 }
21
22 // If not finalized, the request parsing failed. Generate HTTP 400.
23 if (!request->isFinalized()) {
24 return (createStockHttpResponse(request, HttpStatusCode::BAD_REQUEST));
25 }
26
27 // Message has been successfully parsed. Create implementation specific
28 // response to this request.
29 return (createDynamicHttpResponse(request));
30}
31
32}
33}
isc::http::HttpResponseCreator::createHttpResponse
virtual HttpResponsePtr createHttpResponse(HttpRequestPtr request) final
Create HTTP response from HTTP request received.
Definition response_creator.cc:15
isc::http::HttpResponseCreator::createDynamicHttpResponse
virtual HttpResponsePtr createDynamicHttpResponse(HttpRequestPtr request)=0
Creates implementation specific HTTP response.
isc::http::HttpResponseCreator::createStockHttpResponse
virtual HttpResponsePtr createStockHttpResponse(const HttpRequestPtr &request, const HttpStatusCode &status_code) const =0
Creates implementation specific HTTP response.
isc::http::HttpResponseError
Generic exception thrown by HttpResponse class.
Definition response.h:23
isc_throw
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
Definition exceptions/exceptions.h:210
isc::http
Definition auth_config.h:19
isc::http::HttpStatusCode::BAD_REQUEST
@ BAD_REQUEST
Definition response.h:39
isc::http::HttpResponsePtr
boost::shared_ptr< HttpResponse > HttpResponsePtr
Pointer to the HttpResponse object.
Definition response.h:81
isc::http::HttpRequestPtr
boost::shared_ptr< HttpRequest > HttpRequestPtr
Pointer to the HttpRequest object.
Definition request.h:30
isc
Defines the logger used by the top-level component of kea-lfc.
Definition check_exists_add.cc:18
response_creator.h