Rename MapContentType to ProgramContentType ()

This commit is contained in:
Paul Kulchenko 2022-08-24 09:35:17 -07:00 committed by GitHub
parent d2cec808dc
commit 164e2ab27b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 13 deletions
test/tool/net
tool/net

View file

@ -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")

View file

@ -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).

View file

@ -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}, //