470fc1f86f
Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de> Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
241 lines
8.4 KiB
Diff
241 lines
8.4 KiB
Diff
From cfcd8a8f73aa337e8f45d287a79cd9b8e5c51dcd Mon Sep 17 00:00:00 2001
|
|
From: Bernd Kuhls <bernd.kuhls@t-online.de>
|
|
Date: Sun, 5 Jul 2020 11:42:23 +0200
|
|
Subject: [PATCH] Compatibility with libmicrohttpd 0.9.71
|
|
|
|
From the libmicrohttpd 0.9.71 release notes:
|
|
|
|
Furthermore, the release introduces an 'enum MHD_Result' instead of
|
|
defines for MHD_YES/MHD_NO. This is intended to make it easier to check
|
|
for certain API misuse bugs by providing better types (not everything is
|
|
an 'int'). While this does NOT change the binary API, this change
|
|
_will_ cause compiler warnings for all legacy code -- until 'int' is
|
|
replaced with 'enum MHD_Result'
|
|
|
|
Patch sent upstream: https://github.com/etr/libhttpserver/pull/199
|
|
|
|
Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
|
|
---
|
|
src/http_request.cpp | 6 +++---
|
|
src/httpserver/http_request.hpp | 6 +++---
|
|
src/httpserver/http_utils.hpp | 4 ++++
|
|
src/httpserver/webserver.hpp | 14 +++++++-------
|
|
src/webserver.cpp | 22 +++++++++++++---------
|
|
5 files changed, 30 insertions(+), 22 deletions(-)
|
|
|
|
diff --git a/src/http_request.cpp b/src/http_request.cpp
|
|
index 5703663..be342c7 100644
|
|
--- a/src/http_request.cpp
|
|
+++ b/src/http_request.cpp
|
|
@@ -88,7 +88,7 @@ const std::string http_request::get_connection_value(const std::string& key, enu
|
|
return header_c;
|
|
}
|
|
|
|
-int http_request::build_request_header(
|
|
+MHD_Result http_request::build_request_header(
|
|
void *cls,
|
|
enum MHD_ValueKind kind,
|
|
const char *key,
|
|
@@ -189,7 +189,7 @@ const std::string http_request::get_querystring() const
|
|
return querystring;
|
|
}
|
|
|
|
-int http_request::build_request_args(
|
|
+MHD_Result http_request::build_request_args(
|
|
void *cls,
|
|
enum MHD_ValueKind kind,
|
|
const char *key,
|
|
@@ -204,7 +204,7 @@ int http_request::build_request_args(
|
|
return MHD_YES;
|
|
}
|
|
|
|
-int http_request::build_request_querystring(
|
|
+MHD_Result http_request::build_request_querystring(
|
|
void *cls,
|
|
enum MHD_ValueKind kind,
|
|
const char *key,
|
|
diff --git a/src/httpserver/http_request.hpp b/src/httpserver/http_request.hpp
|
|
index 139272b..62e5275 100644
|
|
--- a/src/httpserver/http_request.hpp
|
|
+++ b/src/httpserver/http_request.hpp
|
|
@@ -247,15 +247,15 @@ class http_request
|
|
|
|
unescaper_ptr unescaper = 0x0;
|
|
|
|
- static int build_request_header(void *cls, enum MHD_ValueKind kind,
|
|
+ static MHD_Result build_request_header(void *cls, enum MHD_ValueKind kind,
|
|
const char *key, const char *value
|
|
);
|
|
|
|
- static int build_request_args(void *cls, enum MHD_ValueKind kind,
|
|
+ static MHD_Result build_request_args(void *cls, enum MHD_ValueKind kind,
|
|
const char *key, const char *value
|
|
);
|
|
|
|
- static int build_request_querystring(void *cls, enum MHD_ValueKind kind,
|
|
+ static MHD_Result build_request_querystring(void *cls, enum MHD_ValueKind kind,
|
|
const char *key, const char *value
|
|
);
|
|
|
|
diff --git a/src/httpserver/http_utils.hpp b/src/httpserver/http_utils.hpp
|
|
index 9ad89b4..a812197 100644
|
|
--- a/src/httpserver/http_utils.hpp
|
|
+++ b/src/httpserver/http_utils.hpp
|
|
@@ -53,6 +53,10 @@
|
|
|
|
#define DEFAULT_MASK_VALUE 0xFFFF
|
|
|
|
+#if MHD_VERSION < 0x00097002
|
|
+typedef int MHD_Result;
|
|
+#endif
|
|
+
|
|
namespace httpserver {
|
|
|
|
typedef void(*unescaper_ptr)(std::string&);
|
|
diff --git a/src/httpserver/webserver.hpp b/src/httpserver/webserver.hpp
|
|
index 1ff472b..661b6ee 100644
|
|
--- a/src/httpserver/webserver.hpp
|
|
+++ b/src/httpserver/webserver.hpp
|
|
@@ -195,14 +195,14 @@ class webserver
|
|
enum MHD_RequestTerminationCode toe
|
|
);
|
|
|
|
- static int answer_to_connection
|
|
+ static MHD_Result answer_to_connection
|
|
(
|
|
void* cls, MHD_Connection* connection,
|
|
const char* url, const char* method,
|
|
const char* version, const char* upload_data,
|
|
size_t* upload_data_size, void** con_cls
|
|
);
|
|
- static int post_iterator
|
|
+ static MHD_Result post_iterator
|
|
(
|
|
void *cls,
|
|
enum MHD_ValueKind kind,
|
|
@@ -219,25 +219,25 @@ class webserver
|
|
void **con_cls, int upgrade_socket
|
|
);
|
|
|
|
- int requests_answer_first_step(MHD_Connection* connection,
|
|
+ MHD_Result requests_answer_first_step(MHD_Connection* connection,
|
|
struct details::modded_request* mr
|
|
);
|
|
|
|
- int requests_answer_second_step(MHD_Connection* connection,
|
|
+ MHD_Result requests_answer_second_step(MHD_Connection* connection,
|
|
const char* method, const char* version, const char* upload_data,
|
|
size_t* upload_data_size, struct details::modded_request* mr
|
|
);
|
|
|
|
- int finalize_answer(MHD_Connection* connection,
|
|
+ MHD_Result finalize_answer(MHD_Connection* connection,
|
|
struct details::modded_request* mr, const char* method
|
|
);
|
|
|
|
- int complete_request(MHD_Connection* connection,
|
|
+ MHD_Result complete_request(MHD_Connection* connection,
|
|
struct details::modded_request* mr,
|
|
const char* version, const char* method
|
|
);
|
|
|
|
- friend int policy_callback (void *cls,
|
|
+ friend MHD_Result policy_callback (void *cls,
|
|
const struct sockaddr* addr, socklen_t addrlen
|
|
);
|
|
friend void error_log(void* cls, const char* fmt, va_list ap);
|
|
diff --git a/src/webserver.cpp b/src/webserver.cpp
|
|
index a3104e9..3340eb0 100644
|
|
--- a/src/webserver.cpp
|
|
+++ b/src/webserver.cpp
|
|
@@ -75,6 +75,10 @@
|
|
#define SOCK_CLOEXEC 02000000
|
|
#endif
|
|
|
|
+#if MHD_VERSION < 0x00097002
|
|
+typedef int MHD_Result;
|
|
+#endif
|
|
+
|
|
using namespace std;
|
|
|
|
namespace httpserver
|
|
@@ -82,7 +86,7 @@ namespace httpserver
|
|
|
|
using namespace http;
|
|
|
|
-int policy_callback (void *, const struct sockaddr*, socklen_t);
|
|
+MHD_Result policy_callback (void *, const struct sockaddr*, socklen_t);
|
|
void error_log(void*, const char*, va_list);
|
|
void* uri_log(void*, const char*);
|
|
void access_log(webserver*, string);
|
|
@@ -421,7 +425,7 @@ void webserver::disallow_ip(const string& ip)
|
|
allowances.erase(ip);
|
|
}
|
|
|
|
-int policy_callback (void *cls, const struct sockaddr* addr, socklen_t addrlen)
|
|
+MHD_Result policy_callback (void *cls, const struct sockaddr* addr, socklen_t addrlen)
|
|
{
|
|
if(!(static_cast<webserver*>(cls))->ban_system_enabled) return MHD_YES;
|
|
|
|
@@ -468,7 +472,7 @@ size_t unescaper_func(void * cls, struct MHD_Connection *c, char *s)
|
|
return std::string(s).size();
|
|
}
|
|
|
|
-int webserver::post_iterator (void *cls, enum MHD_ValueKind kind,
|
|
+MHD_Result webserver::post_iterator (void *cls, enum MHD_ValueKind kind,
|
|
const char *key,
|
|
const char *filename,
|
|
const char *content_type,
|
|
@@ -522,7 +526,7 @@ const std::shared_ptr<http_response> webserver::internal_error_page(details::mod
|
|
}
|
|
}
|
|
|
|
-int webserver::requests_answer_first_step(
|
|
+MHD_Result webserver::requests_answer_first_step(
|
|
MHD_Connection* connection,
|
|
struct details::modded_request* mr
|
|
)
|
|
@@ -574,7 +578,7 @@ int webserver::requests_answer_first_step(
|
|
return MHD_YES;
|
|
}
|
|
|
|
-int webserver::requests_answer_second_step(
|
|
+MHD_Result webserver::requests_answer_second_step(
|
|
MHD_Connection* connection, const char* method,
|
|
const char* version, const char* upload_data,
|
|
size_t* upload_data_size, struct details::modded_request* mr
|
|
@@ -597,7 +601,7 @@ int webserver::requests_answer_second_step(
|
|
return MHD_YES;
|
|
}
|
|
|
|
-int webserver::finalize_answer(
|
|
+MHD_Result webserver::finalize_answer(
|
|
MHD_Connection* connection,
|
|
struct details::modded_request* mr,
|
|
const char* method
|
|
@@ -731,10 +735,10 @@ int webserver::finalize_answer(
|
|
mr->dhrs->decorate_response(raw_response);
|
|
to_ret = mr->dhrs->enqueue_response(connection, raw_response);
|
|
MHD_destroy_response(raw_response);
|
|
- return to_ret;
|
|
+ return (MHD_Result) to_ret;
|
|
}
|
|
|
|
-int webserver::complete_request(
|
|
+MHD_Result webserver::complete_request(
|
|
MHD_Connection* connection,
|
|
struct details::modded_request* mr,
|
|
const char* version,
|
|
@@ -750,7 +754,7 @@ int webserver::complete_request(
|
|
return finalize_answer(connection, mr, method);
|
|
}
|
|
|
|
-int webserver::answer_to_connection(void* cls, MHD_Connection* connection,
|
|
+MHD_Result webserver::answer_to_connection(void* cls, MHD_Connection* connection,
|
|
const char* url, const char* method,
|
|
const char* version, const char* upload_data,
|
|
size_t* upload_data_size, void** con_cls
|
|
--
|
|
2.26.2
|
|
|