From f5f56e1a1c4d9e9496fcb9d81131066a964ccd23 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 13 Apr 2024 14:15:43 +0200 Subject: Adding upstream version 2.4.1. Signed-off-by: Daniel Baumann --- src/lib/http/tests/response_test.h | 62 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 src/lib/http/tests/response_test.h (limited to 'src/lib/http/tests/response_test.h') diff --git a/src/lib/http/tests/response_test.h b/src/lib/http/tests/response_test.h new file mode 100644 index 0000000..d342a64 --- /dev/null +++ b/src/lib/http/tests/response_test.h @@ -0,0 +1,62 @@ +// Copyright (C) 2016-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 +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#ifndef HTTP_RESPONSE_TEST_H +#define HTTP_RESPONSE_TEST_H + +#include +#include +#include +#include + +namespace isc { +namespace http { +namespace test { + +/// @brief Base class for test HTTP response. +template +class TestHttpResponseBase : public HttpResponseType { +public: + + /// @brief Constructor. + /// + /// @param version HTTP version for the response. + /// @param status_code HTTP status code. + TestHttpResponseBase(const HttpVersion& version, + const HttpStatusCode& status_code) + : HttpResponseType(version, status_code) { + } + + /// @brief Returns fixed header value. + /// + /// Including fixed header value in the response makes the + /// response deterministic, which is critical for the unit + /// tests. + virtual std::string getDateHeaderValue() const { + return ("Tue, 19 Dec 2016 18:53:35 GMT"); + } + + /// @brief Returns date header value. + std::string generateDateHeaderValue() const { + return (HttpResponseType::getDateHeaderValue()); + } + + /// @brief Sets custom content length. + /// + /// @param content_length Content length value. + void setContentLength(const uint64_t content_length) { + HttpHeaderPtr length_header(new HttpHeader("Content-Length", + boost::lexical_cast + (content_length))); + HttpResponseType::headers_["content-length"] = length_header; + } +}; + +} // namespace test +} // namespace http +} // namespace isc + +#endif -- cgit v1.2.3