summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--commands.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/commands.c b/commands.c
index df9504c..21b0703 100644
--- a/commands.c
+++ b/commands.c
@@ -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;
}