From 9e48363b4022bfc477a0de7cabf9e85cf16531e0 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Tue, 15 Mar 2016 18:25:57 -0400 Subject: multipart-replace-http-server: write an index page --- multipart-replace-http-server.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/multipart-replace-http-server.c b/multipart-replace-http-server.c index 2b30e0f..195ad29 100644 --- a/multipart-replace-http-server.c +++ b/multipart-replace-http-server.c @@ -223,6 +223,29 @@ void connection_handler(int fd) { while (strcmp(line_buf, "\r\n") != 0 && line_len >= 0) line_len = getline(&line_buf, &line_cap, netstream); + if (strcmp(path, "/") == 0) { + error(0, 0, "200 %s", path); + dprintf(fd, + "HTTP/1.1 200 OK\r\n" + "Content-Type: text/html; charset=utf-8\r\n" + "\r\n" + "\n" + "\n" + "\n" + " multipart/x-mixed-replace HTTP server\n" + "\n" + "\n" + " \n" + "\n" + "\n"); + close(fd); + return; + } struct multipart_replace_stream *vidstream = file_get(path); if (vidstream == NULL) { error(0, 0, "404 %s", path); -- cgit v1.2.3