From 72bc1b15821c62d730dfc78672706349cc89327d Mon Sep 17 00:00:00 2001 From: Marcin Siodelski Date: Tue, 16 Apr 2019 21:57:07 +0200 Subject: [PATCH] [#360,!305] Host header is included for all request types. --- src/lib/http/post_request.cc | 7 ++++--- src/lib/http/post_request.h | 7 +++++-- src/lib/http/post_request_json.cc | 7 ++++--- src/lib/http/post_request_json.h | 7 +++++-- 4 files changed, 18 insertions(+), 10 deletions(-) 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. /// -- 2.47.2