From e9d30e5c5a2dc70371f79f00083abfbf7e0de6fb Mon Sep 17 00:00:00 2001 From: Teus Benschop Date: Thu, 28 Dec 2023 20:12:48 +0100 Subject: [PATCH] Beginning of more modern Webserver Request --- bootstrap/bootstrap.cpp | 8 ++++---- bootstrap/bootstrap.h | 4 +++- webserver/webserver.cpp | 4 ++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/bootstrap/bootstrap.cpp b/bootstrap/bootstrap.cpp index 7972d5fc4..6d8665df5 100644 --- a/bootstrap/bootstrap.cpp +++ b/bootstrap/bootstrap.cpp @@ -241,14 +241,14 @@ bool browser_request_security_okay (Webserver_Request * request) // This function is the first function to be called after a client requests a page or file. // Based on the request from the client, // it decides which functions to call to obtain the response. -void bootstrap_index (void * webserver_request) +void bootstrap_index (Webserver_Request& webserver_request) { + Webserver_Request * request = std::addressof(webserver_request); + shared_ptr developer_logic_tracer = nullptr; if (config_globals_log_network) { - developer_logic_tracer = make_shared(webserver_request); + developer_logic_tracer = make_shared(request); } - - Webserver_Request * request = static_cast(webserver_request); // Record the POST request made to the web server. // This can be used for debugging. diff --git a/bootstrap/bootstrap.h b/bootstrap/bootstrap.h index 1afc466be..1ba8c40fa 100644 --- a/bootstrap/bootstrap.h +++ b/bootstrap/bootstrap.h @@ -21,4 +21,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. #include -void bootstrap_index (void * webserver_request); +class Webserver_Request; + +void bootstrap_index (Webserver_Request& webserver_request); diff --git a/webserver/webserver.cpp b/webserver/webserver.cpp index 090f1309f..9005c1891 100644 --- a/webserver/webserver.cpp +++ b/webserver/webserver.cpp @@ -167,7 +167,7 @@ void webserver_process_request (const int connfd, const string& clientaddress) http_parse_post (postdata, &request); // Assemble response. - bootstrap_index (&request); + bootstrap_index (request); http_assemble_response (&request); // Send response to browser. @@ -615,7 +615,7 @@ void secure_webserver_process_request (mbedtls_ssl_config * conf, mbedtls_net_co // Assemble response. if (connection_healthy) { - bootstrap_index (&request); + bootstrap_index (request); http_assemble_response (&request); }