summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2016-03-15 18:25:57 -0400
committerLuke Shumaker <lukeshu@sbcglobal.net>2016-03-15 18:42:32 -0400
commit9e48363b4022bfc477a0de7cabf9e85cf16531e0 (patch)
treefb104505e99858734287f1811322eae76e81f986
parenta18ffc0f109dcff76815eb7acfea67aeb9e42fe2 (diff)
multipart-replace-http-server: write an index page
-rw-r--r--multipart-replace-http-server.c23
1 files changed, 23 insertions, 0 deletions
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"
+ "<!DOCTYPE html>\n"
+ "<html>\n"
+ "<head>\n"
+ " <title>multipart/x-mixed-replace HTTP server</title>\n"
+ "</head>\n"
+ "<body>\n"
+ " <ul>\n"
+ );
+ for (size_t i = 0; i < filec; i++)
+ dprintf(fd, " <li><a href=\"%s\">%s</a></li>\n", filev[i].name, filev[i].name);
+ dprintf(fd,
+ " </ul>\n"
+ "</body>\n"
+ "</html>\n");
+ close(fd);
+ return;
+ }
struct multipart_replace_stream *vidstream = file_get(path);
if (vidstream == NULL) {
error(0, 0, "404 %s", path);