|
|
|
|
@@ -1,32 +1,33 @@
|
|
|
|
|
From 056df008ecb8ab354191b7515199267eb6b84124 Mon Sep 17 00:00:00 2001
|
|
|
|
|
From: bkuhls <bkuhls@users.noreply.github.com>
|
|
|
|
|
Date: Mon, 6 Jul 2020 04:23:21 +0200
|
|
|
|
|
Subject: [PATCH] Compatibility with libmicrohttpd 0.9.71 (#199)
|
|
|
|
|
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:
|
|
|
|
|
|
|
|
|
|
The release introduces an 'enum MHD_Result' instead of
|
|
|
|
|
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'.
|
|
|
|
|
replaced with 'enum MHD_Result'
|
|
|
|
|
|
|
|
|
|
(cherry picked from commit 51b343c6b05dd13cbde0db04984fbf392e9f6df6)
|
|
|
|
|
[Peter: backported to 0.17.5]
|
|
|
|
|
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
|
|
|
|
|
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 | 16 ++++++++--------
|
|
|
|
|
src/webserver.cpp | 24 ++++++++++++++----------
|
|
|
|
|
5 files changed, 32 insertions(+), 24 deletions(-)
|
|
|
|
|
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 973ab33..37035b2 100644
|
|
|
|
|
index 5703663..be342c7 100644
|
|
|
|
|
--- a/src/http_request.cpp
|
|
|
|
|
+++ b/src/http_request.cpp
|
|
|
|
|
@@ -86,7 +86,7 @@ const std::string http_request::get_connection_value(const std::string& key, enu
|
|
|
|
|
@@ -88,7 +88,7 @@ const std::string http_request::get_connection_value(const std::string& key, enu
|
|
|
|
|
return header_c;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -35,7 +36,7 @@ index 973ab33..37035b2 100644
|
|
|
|
|
void *cls,
|
|
|
|
|
enum MHD_ValueKind kind,
|
|
|
|
|
const char *key,
|
|
|
|
|
@@ -187,7 +187,7 @@ const std::string http_request::get_querystring() const
|
|
|
|
|
@@ -189,7 +189,7 @@ const std::string http_request::get_querystring() const
|
|
|
|
|
return querystring;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -44,7 +45,7 @@ index 973ab33..37035b2 100644
|
|
|
|
|
void *cls,
|
|
|
|
|
enum MHD_ValueKind kind,
|
|
|
|
|
const char *key,
|
|
|
|
|
@@ -202,7 +202,7 @@ int http_request::build_request_args(
|
|
|
|
|
@@ -204,7 +204,7 @@ int http_request::build_request_args(
|
|
|
|
|
return MHD_YES;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -54,12 +55,12 @@ index 973ab33..37035b2 100644
|
|
|
|
|
enum MHD_ValueKind kind,
|
|
|
|
|
const char *key,
|
|
|
|
|
diff --git a/src/httpserver/http_request.hpp b/src/httpserver/http_request.hpp
|
|
|
|
|
index 21f2176..6bd371c 100644
|
|
|
|
|
index 139272b..62e5275 100644
|
|
|
|
|
--- a/src/httpserver/http_request.hpp
|
|
|
|
|
+++ b/src/httpserver/http_request.hpp
|
|
|
|
|
@@ -304,15 +304,15 @@ class http_request
|
|
|
|
|
@@ -247,15 +247,15 @@ class http_request
|
|
|
|
|
|
|
|
|
|
unescaper_ptr unescaper;
|
|
|
|
|
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,
|
|
|
|
|
@@ -77,10 +78,10 @@ index 21f2176..6bd371c 100644
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
diff --git a/src/httpserver/http_utils.hpp b/src/httpserver/http_utils.hpp
|
|
|
|
|
index bd3df17..cf18360 100644
|
|
|
|
|
index 9ad89b4..a812197 100644
|
|
|
|
|
--- a/src/httpserver/http_utils.hpp
|
|
|
|
|
+++ b/src/httpserver/http_utils.hpp
|
|
|
|
|
@@ -39,6 +39,10 @@
|
|
|
|
|
@@ -53,6 +53,10 @@
|
|
|
|
|
|
|
|
|
|
#define DEFAULT_MASK_VALUE 0xFFFF
|
|
|
|
|
|
|
|
|
|
@@ -92,10 +93,10 @@ index bd3df17..cf18360 100644
|
|
|
|
|
|
|
|
|
|
typedef void(*unescaper_ptr)(std::string&);
|
|
|
|
|
diff --git a/src/httpserver/webserver.hpp b/src/httpserver/webserver.hpp
|
|
|
|
|
index 2660c70..3c915a1 100644
|
|
|
|
|
index 1ff472b..661b6ee 100644
|
|
|
|
|
--- a/src/httpserver/webserver.hpp
|
|
|
|
|
+++ b/src/httpserver/webserver.hpp
|
|
|
|
|
@@ -201,14 +201,14 @@ class webserver
|
|
|
|
|
@@ -195,14 +195,14 @@ class webserver
|
|
|
|
|
enum MHD_RequestTerminationCode toe
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
@@ -112,23 +113,17 @@ index 2660c70..3c915a1 100644
|
|
|
|
|
(
|
|
|
|
|
void *cls,
|
|
|
|
|
enum MHD_ValueKind kind,
|
|
|
|
|
@@ -225,30 +225,30 @@ class webserver
|
|
|
|
|
@@ -219,25 +219,25 @@ class webserver
|
|
|
|
|
void **con_cls, int upgrade_socket
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
- int bodyless_requests_answer(MHD_Connection* connection,
|
|
|
|
|
+ MHD_Result bodyless_requests_answer(MHD_Connection* connection,
|
|
|
|
|
const char* method, const char* version,
|
|
|
|
|
struct details::modded_request* mr
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
- int bodyfull_requests_answer_first_step(MHD_Connection* connection,
|
|
|
|
|
+ MHD_Result bodyfull_requests_answer_first_step(MHD_Connection* connection,
|
|
|
|
|
- int requests_answer_first_step(MHD_Connection* connection,
|
|
|
|
|
+ MHD_Result requests_answer_first_step(MHD_Connection* connection,
|
|
|
|
|
struct details::modded_request* mr
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
- int bodyfull_requests_answer_second_step(MHD_Connection* connection,
|
|
|
|
|
+ MHD_Result bodyfull_requests_answer_second_step(MHD_Connection* connection,
|
|
|
|
|
- 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
|
|
|
|
|
);
|
|
|
|
|
@@ -150,10 +145,10 @@ index 2660c70..3c915a1 100644
|
|
|
|
|
);
|
|
|
|
|
friend void error_log(void* cls, const char* fmt, va_list ap);
|
|
|
|
|
diff --git a/src/webserver.cpp b/src/webserver.cpp
|
|
|
|
|
index e71c364..ab6b530 100644
|
|
|
|
|
index a3104e9..3340eb0 100644
|
|
|
|
|
--- a/src/webserver.cpp
|
|
|
|
|
+++ b/src/webserver.cpp
|
|
|
|
|
@@ -61,6 +61,10 @@
|
|
|
|
|
@@ -75,6 +75,10 @@
|
|
|
|
|
#define SOCK_CLOEXEC 02000000
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
@@ -164,7 +159,7 @@ index e71c364..ab6b530 100644
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
namespace httpserver
|
|
|
|
|
@@ -68,7 +72,7 @@ namespace httpserver
|
|
|
|
|
@@ -82,7 +86,7 @@ namespace httpserver
|
|
|
|
|
|
|
|
|
|
using namespace http;
|
|
|
|
|
|
|
|
|
|
@@ -173,8 +168,8 @@ index e71c364..ab6b530 100644
|
|
|
|
|
void error_log(void*, const char*, va_list);
|
|
|
|
|
void* uri_log(void*, const char*);
|
|
|
|
|
void access_log(webserver*, string);
|
|
|
|
|
@@ -408,7 +412,7 @@ void webserver::disallow_ip(const string& ip)
|
|
|
|
|
this->allowances.erase(ip);
|
|
|
|
|
@@ -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)
|
|
|
|
|
@@ -182,7 +177,7 @@ index e71c364..ab6b530 100644
|
|
|
|
|
{
|
|
|
|
|
if(!(static_cast<webserver*>(cls))->ban_system_enabled) return MHD_YES;
|
|
|
|
|
|
|
|
|
|
@@ -455,7 +459,7 @@ size_t unescaper_func(void * cls, struct MHD_Connection *c, char *s)
|
|
|
|
|
@@ -468,7 +472,7 @@ size_t unescaper_func(void * cls, struct MHD_Connection *c, char *s)
|
|
|
|
|
return std::string(s).size();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -191,34 +186,25 @@ index e71c364..ab6b530 100644
|
|
|
|
|
const char *key,
|
|
|
|
|
const char *filename,
|
|
|
|
|
const char *content_type,
|
|
|
|
|
@@ -509,7 +513,7 @@ const std::shared_ptr<http_response> webserver::internal_error_page(details::mod
|
|
|
|
|
@@ -522,7 +526,7 @@ const std::shared_ptr<http_response> webserver::internal_error_page(details::mod
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
-int webserver::bodyless_requests_answer(
|
|
|
|
|
+MHD_Result webserver::bodyless_requests_answer(
|
|
|
|
|
MHD_Connection* connection, const char* method,
|
|
|
|
|
const char* version, struct details::modded_request* mr
|
|
|
|
|
)
|
|
|
|
|
@@ -519,7 +523,7 @@ int webserver::bodyless_requests_answer(
|
|
|
|
|
return complete_request(connection, mr, version, method);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
-int webserver::bodyfull_requests_answer_first_step(
|
|
|
|
|
+MHD_Result webserver::bodyfull_requests_answer_first_step(
|
|
|
|
|
-int webserver::requests_answer_first_step(
|
|
|
|
|
+MHD_Result webserver::requests_answer_first_step(
|
|
|
|
|
MHD_Connection* connection,
|
|
|
|
|
struct details::modded_request* mr
|
|
|
|
|
)
|
|
|
|
|
@@ -565,7 +569,7 @@ int webserver::bodyfull_requests_answer_first_step(
|
|
|
|
|
@@ -574,7 +578,7 @@ int webserver::requests_answer_first_step(
|
|
|
|
|
return MHD_YES;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
-int webserver::bodyfull_requests_answer_second_step(
|
|
|
|
|
+MHD_Result webserver::bodyfull_requests_answer_second_step(
|
|
|
|
|
-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
|
|
|
|
|
@@ -583,7 +587,7 @@ int webserver::bodyfull_requests_answer_second_step(
|
|
|
|
|
@@ -597,7 +601,7 @@ int webserver::requests_answer_second_step(
|
|
|
|
|
return MHD_YES;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -227,7 +213,7 @@ index e71c364..ab6b530 100644
|
|
|
|
|
MHD_Connection* connection,
|
|
|
|
|
struct details::modded_request* mr,
|
|
|
|
|
const char* method
|
|
|
|
|
@@ -717,10 +721,10 @@ int webserver::finalize_answer(
|
|
|
|
|
@@ -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);
|
|
|
|
|
@@ -240,7 +226,7 @@ index e71c364..ab6b530 100644
|
|
|
|
|
MHD_Connection* connection,
|
|
|
|
|
struct details::modded_request* mr,
|
|
|
|
|
const char* version,
|
|
|
|
|
@@ -736,7 +740,7 @@ int webserver::complete_request(
|
|
|
|
|
@@ -750,7 +754,7 @@ int webserver::complete_request(
|
|
|
|
|
return finalize_answer(connection, mr, method);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -250,5 +236,5 @@ index e71c364..ab6b530 100644
|
|
|
|
|
const char* version, const char* upload_data,
|
|
|
|
|
size_t* upload_data_size, void** con_cls
|
|
|
|
|
--
|
|
|
|
|
2.20.1
|
|
|
|
|
2.26.2
|
|
|
|
|
|