aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorame <[email protected]>2025-08-09 04:26:08 -0500
committerame <[email protected]>2025-08-09 04:26:08 -0500
commit71995aa7bab0198b3977f33d16ca34e4f628ec3d (patch)
treeac97473949ee4dcaa45ed2bcf1b8256f5180f70b
parent7cc8cade712506c7eeaf3a8e0002cf2313218885 (diff)
dont override Content-Type
-rw-r--r--docs/net/listen.md2
-rw-r--r--src/net/lua.c5
2 files changed, 5 insertions, 2 deletions
diff --git a/docs/net/listen.md b/docs/net/listen.md
index 6b7f12c..333f0f2 100644
--- a/docs/net/listen.md
+++ b/docs/net/listen.md
@@ -132,7 +132,7 @@ res.header["test"] = "wowa"
res:sendfile(filepath, options?)
-res.header["Content-Type"] is set automatically depending on the file extention, using /etc/mime.types, or whatever option was supplied to listen (see listen options)
+res.header["Content-Type"] is set automatically (unless already set) depending on the file extention, using /etc/mime.types, or whatever option was supplied to listen (see listen options)
options table
diff --git a/src/net/lua.c b/src/net/lua.c
index d6bba65..2e46943 100644
--- a/src/net/lua.c
+++ b/src/net/lua.c
@@ -228,8 +228,11 @@ int l_sendfile(lua_State* L){
p_fatal("missing permissions");
}
+ lua_pushstring(L, "Content-Type");
+ lua_gettable(L, header);
+
char* ext = strrchr(path, '.');
- if(ext && mime_type != NULL){
+ if(lua_isnil(L, -1) && ext && mime_type != NULL){
char* content_type = map_get(mime_type, ext + 1);
if(content_type)