shithub: tcp80

Download patch

ref: f04f9abeae796eb44c2fdba5c313147477386b39
parent: 7dd317b68c520d542a3b04a3f55aeca8a3bbbf8b
author: grobe0ba <[email protected]>
date: Mon Aug 1 16:10:12 EDT 2022

add mimetype shits

--- a/tcp80.c
+++ b/tcp80.c
@@ -36,6 +36,7 @@
 	".html", "text/html;charset=utf-8",
 	".txt", "text/plain;charset=utf-8",
 	".md", "text/markdown;charset=utf-8",
+	".css", "text/css;charset=utf-8",
 };
 
 Pair*
@@ -228,8 +229,18 @@
 				f[0], tm->mday, f[1], f[5], f[3], f[4]);
 	}
 	isdir = d && (d->qid.type & QTDIR);
-	if(isdir || cistrstr(path, ".htm"))
+	if(isdir){
 		print("Content-Type: text/html; charset=utf-8\r\n");
+	}else{
+        int i;
+        for(i = 0; i < nelem(ctypemap); i++) { 
+            //print("%s %s %d\n", path, ctypemap[i].suffix, cistrstr(path, ctypemap[i].suffix));
+			if(cistrstr(path, ctypemap[i].suffix)){
+				print("Content-Type: %s\r\n", ctypemap[i].type);
+				break;
+			}
+		}
+	}
 	if(*path == '/')
 		print("Content-Location: %s%s\r\n",
 			urlenc(buf, path, sizeof(buf)), isdir ? "/" : "");