diff --git a/AK/Debug.h.in b/AK/Debug.h.in index 4b6c4d767e..cf6710d188 100644 --- a/AK/Debug.h.in +++ b/AK/Debug.h.in @@ -422,6 +422,10 @@ #cmakedefine01 WASM_TRACE_DEBUG #endif +#ifndef WEBSERVER_DEBUG +#cmakedefine01 WEBSERVER_DEBUG +#endif + #ifndef WINDOWMANAGER_DEBUG #cmakedefine01 WINDOWMANAGER_DEBUG #endif diff --git a/Meta/CMake/all_the_debug_macros.cmake b/Meta/CMake/all_the_debug_macros.cmake index 0377c69045..f1075a59c5 100644 --- a/Meta/CMake/all_the_debug_macros.cmake +++ b/Meta/CMake/all_the_debug_macros.cmake @@ -186,6 +186,7 @@ set(WASM_TRACE_DEBUG ON) set(PDF_DEBUG ON) set(SOLITAIRE_DEBUG ON) set(DDS_DEBUG ON) +set(WEBSERVER_DEBUG ON) # False positive: DEBUG is a flag but it works differently. # set(DEBUG ON) diff --git a/Userland/Services/WebServer/Client.cpp b/Userland/Services/WebServer/Client.cpp index 3c839ce72a..ef40a8de47 100644 --- a/Userland/Services/WebServer/Client.cpp +++ b/Userland/Services/WebServer/Client.cpp @@ -6,6 +6,7 @@ #include "Client.h" #include +#include #include #include #include @@ -50,7 +51,7 @@ void Client::start() } auto request = builder.to_byte_buffer(); - dbgln("Got raw request: '{}'", String::copy(request)); + dbgln_if(WEBSERVER_DEBUG, "Got raw request: '{}'", String::copy(request)); handle_request(request); die(); }; @@ -63,9 +64,11 @@ void Client::handle_request(ReadonlyBytes raw_request) return; auto& request = request_or_error.value(); - dbgln("Got HTTP request: {} {}", request.method_name(), request.resource()); - for (auto& header : request.headers()) { - dbgln(" {} => {}", header.name, header.value); + if constexpr (WEBSERVER_DEBUG) { + dbgln("Got HTTP request: {} {}", request.method_name(), request.resource()); + for (auto& header : request.headers()) { + dbgln(" {} => {}", header.name, header.value); + } } if (request.method() != HTTP::HttpRequest::Method::GET) { @@ -74,7 +77,7 @@ void Client::handle_request(ReadonlyBytes raw_request) } auto requested_path = LexicalPath::join("/", request.resource()).string(); - dbgln("Canonical requested path: '{}'", requested_path); + dbgln_if(WEBSERVER_DEBUG, "Canonical requested path: '{}'", requested_path); StringBuilder path_builder; path_builder.append(m_root_path);