From: Marcin Siodelski Date: Mon, 8 Jan 2018 10:24:16 +0000 (+0100) Subject: [5451] Fix in CA response creator. X-Git-Tag: trac5457_base~4^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e7fda30c2bbefb093f83a8e566059b813a9c1541;p=thirdparty%2Fkea.git [5451] Fix in CA response creator. --- diff --git a/src/bin/agent/ca_response_creator.cc b/src/bin/agent/ca_response_creator.cc index 06b9217347..5eb85170a9 100644 --- a/src/bin/agent/ca_response_creator.cc +++ b/src/bin/agent/ca_response_creator.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2017-2018 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -10,6 +10,7 @@ #include #include #include +#include using namespace isc::data; using namespace isc::http; @@ -26,6 +27,15 @@ HttpResponsePtr CtrlAgentResponseCreator:: createStockHttpResponse(const ConstHttpRequestPtr& request, const HttpStatusCode& status_code) const { + HttpResponsePtr response = createStockHttpResponseInternal(request, status_code); + response->finalize(); + return (response); +} + +HttpResponsePtr +CtrlAgentResponseCreator:: +createStockHttpResponseInternal(const ConstHttpRequestPtr& request, + const HttpStatusCode& status_code) const { // The request hasn't been finalized so the request object // doesn't contain any information about the HTTP version number // used. But, the context should have this data (assuming the @@ -40,7 +50,6 @@ createStockHttpResponse(const ConstHttpRequestPtr& request, } // This will generate the response holding JSON content. HttpResponsePtr response(new HttpResponseJson(http_version, status_code)); - response->finalize(); return (response); } @@ -74,7 +83,7 @@ createDynamicHttpResponse(const ConstHttpRequestPtr& request) { } // The response is ok, so let's create new HTTP response with the status OK. HttpResponseJsonPtr http_response = boost::dynamic_pointer_cast< - HttpResponseJson>(createStockHttpResponse(request, HttpStatusCode::OK)); + HttpResponseJson>(createStockHttpResponseInternal(request, HttpStatusCode::OK)); http_response->setBodyAsJson(response); http_response->finalize(); diff --git a/src/bin/agent/ca_response_creator.h b/src/bin/agent/ca_response_creator.h index fe82d3ea0a..247d21c456 100644 --- a/src/bin/agent/ca_response_creator.h +++ b/src/bin/agent/ca_response_creator.h @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2017-2018 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -57,6 +57,16 @@ public: private: + /// @brief Creates unfinalized stock HTTP response. + /// + /// @param request Pointer to an object representing HTTP request. + /// @param status_code Status code of the response. + /// @return Pointer to an @ref isc::http::HttpResponseJson object + /// representing stock HTTP response. + http::HttpResponsePtr + createStockHttpResponseInternal(const http::ConstHttpRequestPtr& request, + const http::HttpStatusCode& status_code) const; + /// @brief Creates implementation specific HTTP response. /// /// @param request Pointer to an object representing HTTP request.