From 514a4e326f623f753dd37d4a921ada36dc9af9c0 Mon Sep 17 00:00:00 2001
From: Louis Sautier
Date: Thu, 20 Aug 2020 18:25:48 +0200
Subject: [PATCH 1/4] =?UTF-8?q?Fix=20=E2=80=98fs::copy=5Foption=E2=80=99?=
=?UTF-8?q?=20has=20not=20been=20declared=20with=20boost=201.74.0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
It was deprecated in
https://github.com/boostorg/filesystem/commit/f199152b7df036ff1606c85e4ea1b28edfeda6cc
---
lib/base/utility.cpp | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/lib/base/utility.cpp b/lib/base/utility.cpp
index 1add7616c..d8e6f20b0 100644
--- a/lib/base/utility.cpp
+++ b/lib/base/utility.cpp
@@ -725,7 +725,11 @@ void Utility::CopyFile(const String& source, const String& target)
{
namespace fs = boost::filesystem;
+#if BOOST_VERSION >= 107400
+ fs::copy_file(fs::path(source.Begin(), source.End()), fs::path(target.Begin(), target.End()), fs::copy_options::overwrite_existing);
+#else /* BOOST_VERSION */
fs::copy_file(fs::path(source.Begin(), source.End()), fs::path(target.Begin(), target.End()), fs::copy_option::overwrite_if_exists);
+#endif /* BOOST_VERSION */
}
/*
From 590bd7ba1d172ef49eff8a0cb717bc91fc183f10 Mon Sep 17 00:00:00 2001
From: "Alexander A. Klimov"
Date: Mon, 14 Dec 2020 15:59:56 +0100
Subject: [PATCH 2/4] Define BOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT
... to enable compiling with Boost v1.74.
refs #8185
---
CMakeLists.txt | 3 +++
1 file changed, 3 insertions(+)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0f92e092f..7331f0cf6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -165,6 +165,9 @@ add_definitions(-DBOOST_COROUTINES_NO_DEPRECATION_WARNING)
add_definitions(-DBOOST_FILESYSTEM_NO_DEPRECATED)
+# Required for Boost v1.74+
+add_definitions(-DBOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT)
+
link_directories(${Boost_LIBRARY_DIRS})
include_directories(${Boost_INCLUDE_DIRS})
From 058d2673972bc799bbb42d3fc2dc063b002b159d Mon Sep 17 00:00:00 2001
From: Julian Brost
Date: Tue, 22 Dec 2020 14:32:56 +0100
Subject: [PATCH 3/4] Use content_length method for setting the Content-Length
header
Boost.Beast changed the signature of the previously used generic `set`
method so that it no longer accepts integer types, however there is
alreay a more specific method for setting the Content-Length header, so
use this one instead.
---
lib/perfdata/elasticsearchwriter.cpp | 2 +-
lib/perfdata/influxdbwriter.cpp | 2 +-
lib/remote/configfileshandler.cpp | 2 +-
lib/remote/httpserverconnection.cpp | 10 +++++-----
lib/remote/httputility.cpp | 2 +-
lib/remote/infohandler.cpp | 2 +-
6 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/lib/perfdata/elasticsearchwriter.cpp b/lib/perfdata/elasticsearchwriter.cpp
index 7798ad8dc..1cda8afce 100644
--- a/lib/perfdata/elasticsearchwriter.cpp
+++ b/lib/perfdata/elasticsearchwriter.cpp
@@ -494,7 +494,7 @@ void ElasticsearchWriter::SendRequest(const String& body)
request.set(http::field::authorization, "Basic " + Base64::Encode(username + ":" + password));
request.body() = body;
- request.set(http::field::content_length, request.body().size());
+ request.content_length(request.body().size());
/* Don't log the request body to debug log, this is already done above. */
Log(LogDebug, "ElasticsearchWriter")
diff --git a/lib/perfdata/influxdbwriter.cpp b/lib/perfdata/influxdbwriter.cpp
index 1e02e5213..8e64c4c6a 100644
--- a/lib/perfdata/influxdbwriter.cpp
+++ b/lib/perfdata/influxdbwriter.cpp
@@ -504,7 +504,7 @@ void InfluxdbWriter::Flush()
request.set(http::field::host, url->GetHost() + ":" + url->GetPort());
request.body() = body;
- request.set(http::field::content_length, request.body().size());
+ request.content_length(request.body().size());
try {
if (stream.first) {
diff --git a/lib/remote/configfileshandler.cpp b/lib/remote/configfileshandler.cpp
index d714f4d86..6013d9722 100644
--- a/lib/remote/configfileshandler.cpp
+++ b/lib/remote/configfileshandler.cpp
@@ -84,7 +84,7 @@ bool ConfigFilesHandler::HandleRequest(
response.result(http::status::ok);
response.set(http::field::content_type, "application/octet-stream");
response.body() = content;
- response.set(http::field::content_length, response.body().size());
+ response.content_length(response.body().size());
} catch (const std::exception& ex) {
HttpUtility::SendJsonError(response, params, 500, "Could not read file.",
DiagnosticInformation(ex));
diff --git a/lib/remote/httpserverconnection.cpp b/lib/remote/httpserverconnection.cpp
index 3e0a4f27f..e32e6dc90 100644
--- a/lib/remote/httpserverconnection.cpp
+++ b/lib/remote/httpserverconnection.cpp
@@ -186,7 +186,7 @@ bool EnsureValidHeaders(
} else {
response.set(http::field::content_type, "text/html");
response.body() = String("Bad Request
") + errorMsg + "
";
- response.set(http::field::content_length, response.body().size());
+ response.content_length(response.body().size());
}
response.set(http::field::connection, "close");
@@ -259,7 +259,7 @@ bool HandleAccessControl(
response.set(http::field::access_control_allow_methods, "GET, POST, PUT, DELETE");
response.set(http::field::access_control_allow_headers, "Authorization, X-HTTP-Method-Override");
response.body() = "Preflight OK";
- response.set(http::field::content_length, response.body().size());
+ response.content_length(response.body().size());
response.set(http::field::connection, "close");
boost::system::error_code ec;
@@ -290,7 +290,7 @@ bool EnsureAcceptHeader(
response.result(http::status::bad_request);
response.set(http::field::content_type, "text/html");
response.body() = "Accept header is missing or not set to 'application/json'.
";
- response.set(http::field::content_length, response.body().size());
+ response.content_length(response.body().size());
response.set(http::field::connection, "close");
boost::system::error_code ec;
@@ -331,7 +331,7 @@ bool EnsureAuthenticatedUser(
} else {
response.set(http::field::content_type, "text/html");
response.body() = "Unauthorized. Please check your user credentials.
";
- response.set(http::field::content_length, response.body().size());
+ response.content_length(response.body().size());
}
boost::system::error_code ec;
@@ -423,7 +423,7 @@ bool EnsureValidBody(
} else {
response.set(http::field::content_type, "text/html");
response.body() = String("Bad Request
") + ec.message() + "
";
- response.set(http::field::content_length, response.body().size());
+ response.content_length(response.body().size());
}
response.set(http::field::connection, "close");
diff --git a/lib/remote/httputility.cpp b/lib/remote/httputility.cpp
index 91902ba50..a2142e5d8 100644
--- a/lib/remote/httputility.cpp
+++ b/lib/remote/httputility.cpp
@@ -58,7 +58,7 @@ void HttpUtility::SendJsonBody(boost::beast::http::response& response,
diff --git a/lib/remote/infohandler.cpp b/lib/remote/infohandler.cpp
index 18c18c0e0..80ebba77b 100644
--- a/lib/remote/infohandler.cpp
+++ b/lib/remote/infohandler.cpp
@@ -92,7 +92,7 @@ bool InfoHandler::HandleRequest(
body += R"(More information about API requests is available in the documentation.