From 2fc258dc9e58b2a2646d09778026a0a82fb9210e Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Mon, 16 Aug 2010 16:19:25 +0200 Subject: Return HTTP 404 in commands_get_raw(). --- commands.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/commands.c b/commands.c index df9504c..21b0703 100644 --- a/commands.c +++ b/commands.c @@ -5,6 +5,20 @@ #include #include +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; } -- cgit v1.2.3