[libsoup] examples/simple-httpd.c: Fix handling of directories
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsoup] examples/simple-httpd.c: Fix handling of directories
- Date: Mon, 16 Jul 2018 14:11:54 +0000 (UTC)
commit a77b81901db248f6d6af26f10ace3af50048db12
Author: Mooffie <mooffie gmail com>
Date: Fri Jun 15 17:05:37 2018 +0300
examples/simple-httpd.c: Fix handling of directories
A bug introduced in commit 53a3dd24e5b572fafa79e7cc4cdc4eb17d193e3e (a
copy/paste mistake has replaced a variable name) causes the example
httpd to not handle directories correctly.
Additionally, we add a comment recommending programmers to provide a
descriptive error message. This could give users and programmers a hint
as to what went wrong.
Fixes #2
examples/simple-httpd.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
---
diff --git a/examples/simple-httpd.c b/examples/simple-httpd.c
index 0458203b..ab755b96 100644
--- a/examples/simple-httpd.c
+++ b/examples/simple-httpd.c
@@ -77,6 +77,11 @@ 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), and include in it
+ * the request path, as otherwise some browsers (Firefox, WebKit) only
+ * show a blank page, confusing the user.
+ */
return;
}
@@ -96,7 +101,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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]