From: Marcin Siodelski Date: Tue, 16 Apr 2019 19:57:07 +0000 (+0200) Subject: [#360,!305] Host header is included for all request types. X-Git-Tag: Kea-1.6.0-beta~179 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5276c09101931ffff6bcf72a001e9e445c7f8344;p=thirdparty%2Fkea.git [#360,!305] Host header is included for all request types. --- diff --git a/src/lib/http/post_request.cc b/src/lib/http/post_request.cc index e40c67f7c2..f7a8090fe9 100644 --- a/src/lib/http/post_request.cc +++ b/src/lib/http/post_request.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2016-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2016-2019 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 @@ -19,8 +19,9 @@ PostHttpRequest::PostHttpRequest() } PostHttpRequest::PostHttpRequest(const Method& method, const std::string& uri, - const HttpVersion& version) - : HttpRequest(method, uri, version) { + const HttpVersion& version, + const HostHttpHeader& host_header) + : HttpRequest(method, uri, version, host_header) { requireHttpMethod(Method::HTTP_POST); requireHeader("Content-Length"); requireHeader("Content-Type"); diff --git a/src/lib/http/post_request.h b/src/lib/http/post_request.h index 733a4ae975..1426087944 100644 --- a/src/lib/http/post_request.h +++ b/src/lib/http/post_request.h @@ -1,4 +1,4 @@ -// Copyright (C) 2016-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2016-2019 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 @@ -37,7 +37,10 @@ public: /// @param method HTTP method, e.g. POST. /// @param uri URI. /// @param version HTTP version. - PostHttpRequest(const Method& method, const std::string& uri, const HttpVersion& version); + /// @param host_header Host header to be included in the request. The default + /// is the empty Host header. + PostHttpRequest(const Method& method, const std::string& uri, const HttpVersion& version, + const HostHttpHeader& host_header = HostHttpHeader()); }; diff --git a/src/lib/http/post_request_json.cc b/src/lib/http/post_request_json.cc index 163a6e7f0c..887af204e9 100644 --- a/src/lib/http/post_request_json.cc +++ b/src/lib/http/post_request_json.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2016-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2016-2019 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 @@ -19,8 +19,9 @@ PostHttpRequestJson::PostHttpRequestJson() } PostHttpRequestJson::PostHttpRequestJson(const Method& method, const std::string& uri, - const HttpVersion& version) - : PostHttpRequest(method, uri, version) { + const HttpVersion& version, + const HostHttpHeader& host_header) + : PostHttpRequest(method, uri, version, host_header) { requireHeaderValue("Content-Type", "application/json"); context()->headers_.push_back(HttpHeaderContext("Content-Type", "application/json")); } diff --git a/src/lib/http/post_request_json.h b/src/lib/http/post_request_json.h index e3d9829ff6..f4f37b3edd 100644 --- a/src/lib/http/post_request_json.h +++ b/src/lib/http/post_request_json.h @@ -1,4 +1,4 @@ -// Copyright (C) 2016-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2016-2019 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 @@ -50,8 +50,11 @@ public: /// @param method HTTP method, e.g. POST. /// @param uri URI. /// @param version HTTP version. + /// @param host_header Host header to be included in the request. The default + /// is the empty Host header. explicit PostHttpRequestJson(const Method& method, const std::string& uri, - const HttpVersion& version); + const HttpVersion& version, + const HostHttpHeader& host_header = HostHttpHeader()); /// @brief Complete parsing of the HTTP request. ///