diff --git a/test/tool/net/lua_test.lua b/test/tool/net/lua_test.lua index e687b4e8a..9c8a95436 100644 --- a/test/tool/net/lua_test.lua +++ b/test/tool/net/lua_test.lua @@ -22,11 +22,11 @@ assert("\e" == "\x1b") assert("hi" * 3 == "hihihi") assert("hello %d" % {123} == "hello 123") --- test MapContentType -assert(MapContentType("txt") == "text/plain") -assert(MapContentType("htm") == "text/html") -assert(MapContentType("abc.htm") == "text/html") -assert(MapContentType("1") == nil) -MapContentType("1", "text/x-foo") -assert(MapContentType("1"), "text/x-foo") -assert(MapContentType("file.1"), "text/x-foo") +-- test ProgramContentType +assert(ProgramContentType("txt") == "text/plain") +assert(ProgramContentType("htm") == "text/html") +assert(ProgramContentType("abc.htm") == "text/html") +assert(ProgramContentType("1") == nil) +ProgramContentType("1", "text/x-foo") +assert(ProgramContentType("1"), "text/x-foo") +assert(ProgramContentType("file.1"), "text/x-foo") diff --git a/tool/net/help.txt b/tool/net/help.txt index 3b3971cf7..a0b7bdb1b 100644 --- a/tool/net/help.txt +++ b/tool/net/help.txt @@ -1271,9 +1271,6 @@ FUNCTIONS flag was used. If slurping large file into memory is a concern, then consider using ServeAsset which can serve directly off disk. - MapContentType(ext:str[, contenttype:str]) → str - Sets or returns content type associated with a file extension. - StoreAsset(path:str, data:str[, mode:int]) Stores asset to executable's ZIP central directory. This currently happens in an append-only fashion and is still @@ -1375,6 +1372,9 @@ FUNCTIONS ProgramCertificate(Slurp("/etc/letsencrypt.lol/fullchain.pem")) for local file system only. + ProgramContentType(ext:str[, contenttype:str]) → str + Sets or returns content type associated with a file extension. + ProgramHeader(name:str,value:str) Appends HTTP header to the header buffer for all responses (whereas SetHeader only appends a header to the current response buffer). diff --git a/tool/net/redbean.c b/tool/net/redbean.c index 3c2f68f3c..567471a0f 100644 --- a/tool/net/redbean.c +++ b/tool/net/redbean.c @@ -4630,7 +4630,7 @@ static const char *GetContentTypeExt(const char *path, size_t n) { return r; } -static int LuaMapContentType(lua_State *L) { +static int LuaProgramContentType(lua_State *L) { const char *ext = luaL_checkstring(L, 1); const char *ct; int n = lua_gettop(L); @@ -4869,7 +4869,6 @@ static const luaL_Reg kLuaFuncs[] = { {"Lemur64", LuaLemur64}, // {"LoadAsset", LuaLoadAsset}, // {"Log", LuaLog}, // - {"MapContentType", LuaMapContentType}, // {"Md5", LuaMd5}, // {"MeasureEntropy", LuaMeasureEntropy}, // {"ParseHost", LuaParseHost}, // @@ -4881,6 +4880,7 @@ static const luaL_Reg kLuaFuncs[] = { {"ProgramAddr", LuaProgramAddr}, // {"ProgramBrand", LuaProgramBrand}, // {"ProgramCache", LuaProgramCache}, // + {"ProgramContentType", LuaProgramContentType}, // {"ProgramDirectory", LuaProgramDirectory}, // {"ProgramGid", LuaProgramGid}, // {"ProgramHeader", LuaProgramHeader}, //