From 888dd7c3c4c51038982b2bd9af726206ff72d71c Mon Sep 17 00:00:00 2001 From: Mooffie Date: Fri, 15 Jun 2018 17:05:37 +0300 Subject: [PATCH] examples/simple-httpd.c fails to handle directories --- examples/simple-httpd.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/examples/simple-httpd.c b/examples/simple-httpd.c index 0458203b..f8a98ad2 100644 --- a/examples/simple-httpd.c +++ b/examples/simple-httpd.c @@ -77,6 +77,10 @@ do_get (SoupServer *server, SoupMessage *msg, const char *path) soup_message_set_status (msg, SOUP_STATUS_NOT_FOUND); else soup_message_set_status (msg, SOUP_STATUS_INTERNAL_SERVER_ERROR); + /* In a real program you should also provide some text explaining the error + * to the user (via soup_message_set_response), as otherwise some browsers + * (Firefox, WebKit) show a blank page, confusing the user. + */ return; } @@ -96,7 +100,7 @@ do_get (SoupServer *server, SoupMessage *msg, const char *path) } index_path = g_strdup_printf ("%s/index.html", path); - if (g_stat (path, &st) != -1) { + if (g_stat (index_path, &st) != -1) { do_get (server, msg, index_path); g_free (index_path); return; -- 2.17.1