From af195e3f2cd7c096420e0856b53b813bf5259103 Mon Sep 17 00:00:00 2001 From: "F. Duncanh" Date: Mon, 3 Jun 2024 05:14:53 -0400 Subject: [PATCH] improved debug log on httpd: see ALL requests received --- lib/httpd.c | 13 +++++++++++-- lib/raop.c | 1 - 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/httpd.c b/lib/httpd.c index 854fed9..aae0f10 100644 --- a/lib/httpd.c +++ b/lib/httpd.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "httpd.h" #include "netutils.h" @@ -243,7 +244,8 @@ httpd_thread(void *arg) httpd_t *httpd = arg; char buffer[1024]; int i; - + bool logger_debug = (logger_get_level(httpd->logger) >= LOGGER_DEBUG); + assert(httpd); while (1) { @@ -336,7 +338,7 @@ httpd_thread(void *arg) assert(connection->request); } - logger_log(httpd->logger, LOGGER_DEBUG, "httpd receiving on socket %d", connection->socket_fd); + logger_log(httpd->logger, LOGGER_DEBUG, "httpd receiving on socket %d, connection %d", connection->socket_fd, i); ret = recv(connection->socket_fd, buffer, sizeof(buffer), 0); if (ret == 0) { logger_log(httpd->logger, LOGGER_INFO, "Connection closed for socket %d", connection->socket_fd); @@ -356,6 +358,13 @@ httpd_thread(void *arg) if (http_request_is_complete(connection->request)) { http_response_t *response = NULL; // Callback the received data to raop + if (logger_debug) { + const char *method = http_request_get_method(connection->request); + const char *url = http_request_get_url(connection->request); + const char *protocol = http_request_get_protocol(connection->request); + logger_log(httpd->logger, LOGGER_INFO, "httpd request received on socket %d, connection %d, " + "method = %s, url = %s, protocol = %s", connection->socket_fd, i, method, url, protocol); + } httpd->callbacks.conn_request(connection->user_data, connection->request, &response); http_request_destroy(connection->request); connection->request = NULL; diff --git a/lib/raop.c b/lib/raop.c index cc3d3f9..e94f116 100644 --- a/lib/raop.c +++ b/lib/raop.c @@ -163,7 +163,6 @@ conn_request(void *ptr, http_request_t *request, http_response_t **response) { int response_datalen = 0; raop_conn_t *conn = ptr; - logger_log(conn->raop->logger, LOGGER_DEBUG, "conn_request"); bool logger_debug = (logger_get_level(conn->raop->logger) >= LOGGER_DEBUG); const char *method = http_request_get_method(request);