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