From 6e152ae37c4075ff2a39298d450bf58258ceffe1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=99emysl=20Janouch?= Date: Thu, 18 Oct 2018 07:17:06 +0200 Subject: More debugging information for static file serving --- demo-json-rpc-server.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/demo-json-rpc-server.c b/demo-json-rpc-server.c index e210788..34cd378 100644 --- a/demo-json-rpc-server.c +++ b/demo-json-rpc-server.c @@ -1642,6 +1642,15 @@ request_start (struct request *self, struct str_map *headers) // Another way we could get rid of the continue_ argument is via adding // some way of marking the request as finished from within the handler. + if (g_debug_mode) + { + struct str_map_iter iter = str_map_iter_make (headers); + const char *value; + while ((value = str_map_iter_next (&iter))) + print_debug ("%s: %s", iter.link->key, value); + print_debug ("--"); + } + bool continue_ = true; LIST_FOR_EACH (struct request_handler, handler, self->ctx->handlers) if (handler->try_handle (self, headers, &continue_)) @@ -1800,15 +1809,19 @@ request_handler_static_try_handle return false; } + // TODO: implement HEAD, we don't get that for free; + // probably implies adding Content-Length const char *method = str_map_find (headers, "REQUEST_METHOD"); if (!method || strcmp (method, "GET")) return false; // TODO: look at , REQUEST_URI in the headers const char *path_info = str_map_find (headers, "PATH_INFO"); + if (!path_info) + path_info = str_map_find (headers, "REQUEST_URI"); if (!path_info) { - print_debug ("PATH_INFO not defined"); + print_debug ("neither PATH_INFO nor REQUEST_URI was defined"); return false; } @@ -1816,6 +1829,7 @@ request_handler_static_try_handle // Being able to read /etc/passwd would be rather embarrasing char *suffix = canonicalize_url_path (path_info); char *path = xstrdup_printf ("%s%s", root, suffix); + print_debug ("trying to statically serve %s", path); // TODO: check that this is a regular file FILE *fp = fopen (path, "rb"); -- cgit v1.2.3