Commit a77b8190 authored by Mooffie's avatar Mooffie

examples/simple-httpd.c: Fix handling of directories

A bug introduced in commit 53a3dd24 (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
parent 4279980f
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment