diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2010-08-16 16:19:25 +0200 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2010-08-16 16:19:25 +0200 |
commit | 2fc258dc9e58b2a2646d09778026a0a82fb9210e (patch) | |
tree | 79754bf80ae84b5144c7cf50e52b15368e069fca | |
parent | 168eb00a7af31e6762773988d3584efcd134cdb9 (diff) |
Return HTTP 404 in commands_get_raw().
-rw-r--r-- | commands.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -5,6 +5,20 @@ #include <string.h> #include <gio/gio.h> +static void send_404(GSocketConnection *connection) { + GError *error = NULL; + GString *string = g_string_new(NULL); + g_string_append(string, "HTTP/1.1 404 Not Found\r\n"); + g_string_append(string, "\r\n"); + + GOutputStream *os = g_io_stream_get_output_stream((GIOStream*)connection); + if(g_output_stream_write_all(os, string->str, string->len, NULL, NULL, + &error) == FALSE) { + g_warning(error->message); + g_error_free(error); + } +} + static void commands_list(GSocketConnection *connection, const gchar *cmd) { GError *error = NULL; gchar **data = g_strsplit(cmd, " ", 2); @@ -65,6 +79,7 @@ static void commands_get_raw(GSocketConnection *connection, const gchar *cmd) { if(f == NULL) { g_warning("couldn't find %s", path); + send_404(connection); goto commands_get_raw_free_path; } |