summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2020-05-09 21:59:23 +0200
committerLeah Neukirchen <leah@vuxu.org>2020-05-09 21:59:23 +0200
commit25dae8d17f31a9190dd13a9bb3bc10ff7ffce79d (patch)
tree3d4b9e19fec307e376ddb75920b290bc96ae32c1
parent6659fec29dd78ffc6eb2c85eb01c264f28c79038 (diff)
downloadhittpd-25dae8d17f31a9190dd13a9bb3bc10ff7ffce79d.tar.gz
hittpd-25dae8d17f31a9190dd13a9bb3bc10ff7ffce79d.tar.xz
hittpd-25dae8d17f31a9190dd13a9bb3bc10ff7ffce79d.zip
allow custom mime types
-rw-r--r--hittpd.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/hittpd.c b/hittpd.c
index 95fc11e..857153e 100644
--- a/hittpd.c
+++ b/hittpd.c
@@ -103,6 +103,7 @@ int vhost = 0;
 int quiet = 0;
 int show_index = 1;
 int only_public = 0;
+const char *custom_mimetypes = "";
 
 static int
 on_url(http_parser *p, const char *s, size_t l)
@@ -462,7 +463,9 @@ mimetype(char *ext)
 	if (!ext)
 		return default_mimetype;
 
-	char *x = strstr(mimetypes, ext);
+	char *x = strstr(custom_mimetypes, ext);
+	if (!x)
+		x = strstr(mimetypes, ext);
 
 	if (x && x[-1] == ':' && x[strlen(ext)] == '=') {
 		char *t = type;
@@ -886,9 +889,10 @@ main(int argc, char *argv[])
 	char *uds = 0;
 
 	int c;
-        while ((c = getopt(argc, argv, "h:p:qu:IHPV")) != -1)
+        while ((c = getopt(argc, argv, "h:m:p:qu:IHPV")) != -1)
 		switch (c) {
 		case 'h': host = optarg; break;
+		case 'm': custom_mimetypes = optarg; break;
 		case 'p': port = optarg; break;
 		case 'u': uds = optarg; break;
 		case 'q': quiet = 1; break;
@@ -899,6 +903,7 @@ main(int argc, char *argv[])
                 default:
                         fprintf(stderr,
 			    "Usage: %s [-h HOST] [-p PORT] [-u SOCKET] "
+			    "[-m :.ext=mime/type:...] "
 			    "[-IHPVq] [DIRECTORY]\n", argv[0]);
                         exit(1);
 		}