summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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);