Rename GetLastModified to GetAssetLastModified and IsCompressed to IsAssetCompressed

This commit is contained in:
Paul Kulchenko 2022-06-22 22:13:24 -07:00
parent 36b271cbc2
commit 83f094bb5a
3 changed files with 20 additions and 10 deletions

View file

@ -317,7 +317,7 @@ local function main()
if not IsAcceptablePath(paths[i]) then if not IsAcceptablePath(paths[i]) then
Write(' <small>[BLOCKED]</small>') Write(' <small>[BLOCKED]</small>')
end end
if not IsCompressed(paths[i]) then if not IsAssetCompressed(paths[i]) then
Write(' <small>[UNCOMPRESSED]</small>') Write(' <small>[UNCOMPRESSED]</small>')
end end
if (GetAssetMode(paths[i]) & 0xF000) == 0x4000 then if (GetAssetMode(paths[i]) & 0xF000) == 0x4000 then
@ -325,7 +325,7 @@ local function main()
end end
Write('<br>\r\n') Write('<br>\r\n')
Write('Modified: ') Write('Modified: ')
Write(FormatHttpDateTime(GetLastModifiedTime(paths[i]))) Write(FormatHttpDateTime(GetAssetLastModifiedTime(paths[i])))
Write('<br>\r\n') Write('<br>\r\n')
Write('Mode: ') Write('Mode: ')
Write("0%o" % {GetAssetMode(paths[i])}) Write("0%o" % {GetAssetMode(paths[i])})

View file

@ -769,13 +769,21 @@ FUNCTIONS
directory. directory.
Also available as GetComment (deprecated). Also available as GetComment (deprecated).
GetAssetLastModifiedTime(path:str) → seconds:number
Returns UNIX timestamp for modification time of a ZIP asset (or
local file if the -D flag is used).
If both a file and a ZIP asset are present, then the file is used.
Also available as GetLastModifiedTime (deprecated).
GetAssetMode(path:str) → int GetAssetMode(path:str) → int
Returns UNIX-style octal mode for ZIP asset (or local file if the Returns UNIX-style octal mode for ZIP asset (or local file if the
-D flag is used) -D flag is used).
If both a file and a ZIP asset are present, then the file is used.
GetAssetSize(path:str) → int GetAssetSize(path:str) → int
Returns byte size of uncompressed contents of ZIP asset (or local Returns byte size of uncompressed contents of ZIP asset (or local
file if the -D flag is used) file if the -D flag is used).
If both a file and a ZIP asset are present, then the file is used.
GetBody() → str GetBody() → str
Returns the request message body if present or an empty string. Returns the request message body if present or an empty string.
@ -971,9 +979,10 @@ v See khttprepeatable.c. Those headers will not be folded. Standard
Returns true if IP address is part of the localhost network Returns true if IP address is part of the localhost network
(127.0.0.0/8). (127.0.0.0/8).
IsCompressed(path:str) → bool IsAssetCompressed(path:str) → bool
Returns true if ZIP artifact at path is stored on disk using Returns true if ZIP artifact at path is stored on disk using
DEFLATE compression. DEFLATE compression.
Also available as IsCompressed (deprecated).
IndentLines(str[,int]) → str IndentLines(str[,int]) → str
Adds spaces to beginnings of multiline string. If the int Adds spaces to beginnings of multiline string. If the int

View file

@ -4841,7 +4841,7 @@ static int LuaGetAssetMode(lua_State *L) {
return 1; return 1;
} }
static int LuaGetLastModifiedTime(lua_State *L) { static int LuaGetAssetLastModifiedTime(lua_State *L) {
size_t pathlen; size_t pathlen;
struct Asset *a; struct Asset *a;
const char *path; const char *path;
@ -4879,7 +4879,7 @@ static int LuaGetAssetSize(lua_State *L) {
return 1; return 1;
} }
static int LuaIsCompressed(lua_State *L) { static int LuaIsAssetCompressed(lua_State *L) {
size_t pathlen; size_t pathlen;
struct Asset *a; struct Asset *a;
const char *path; const char *path;
@ -5033,6 +5033,7 @@ static const luaL_Reg kLuaFuncs[] = {
{"FormatHttpDateTime", LuaFormatHttpDateTime}, // {"FormatHttpDateTime", LuaFormatHttpDateTime}, //
{"FormatIp", LuaFormatIp}, // {"FormatIp", LuaFormatIp}, //
{"GetAssetComment", LuaGetAssetComment}, // {"GetAssetComment", LuaGetAssetComment}, //
{"GetAssetLastModifiedTime", LuaGetAssetLastModifiedTime}, //
{"GetAssetMode", LuaGetAssetMode}, // {"GetAssetMode", LuaGetAssetMode}, //
{"GetAssetSize", LuaGetAssetSize}, // {"GetAssetSize", LuaGetAssetSize}, //
{"GetBody", LuaGetBody}, // {"GetBody", LuaGetBody}, //
@ -5052,7 +5053,6 @@ static const luaL_Reg kLuaFuncs[] = {
{"GetHostOs", LuaGetHostOs}, // {"GetHostOs", LuaGetHostOs}, //
{"GetHttpReason", LuaGetHttpReason}, // {"GetHttpReason", LuaGetHttpReason}, //
{"GetHttpVersion", LuaGetHttpVersion}, // {"GetHttpVersion", LuaGetHttpVersion}, //
{"GetLastModifiedTime", LuaGetLastModifiedTime}, //
{"GetLogLevel", LuaGetLogLevel}, // {"GetLogLevel", LuaGetLogLevel}, //
{"GetMethod", LuaGetMethod}, // {"GetMethod", LuaGetMethod}, //
{"GetMonospaceWidth", LuaGetMonospaceWidth}, // {"GetMonospaceWidth", LuaGetMonospaceWidth}, //
@ -5079,7 +5079,7 @@ static const luaL_Reg kLuaFuncs[] = {
{"IsAcceptablePath", LuaIsAcceptablePath}, // {"IsAcceptablePath", LuaIsAcceptablePath}, //
{"IsAcceptablePort", LuaIsAcceptablePort}, // {"IsAcceptablePort", LuaIsAcceptablePort}, //
{"IsClientUsingSsl", LuaIsClientUsingSsl}, // {"IsClientUsingSsl", LuaIsClientUsingSsl}, //
{"IsCompressed", LuaIsCompressed}, // {"IsAssetCompressed", LuaIsAssetCompressed}, //
{"IsDaemon", LuaIsDaemon}, // {"IsDaemon", LuaIsDaemon}, //
{"IsHeaderRepeatable", LuaIsHeaderRepeatable}, // {"IsHeaderRepeatable", LuaIsHeaderRepeatable}, //
{"IsHiddenPath", LuaIsHiddenPath}, // {"IsHiddenPath", LuaIsHiddenPath}, //
@ -5166,7 +5166,8 @@ static const luaL_Reg kLuaFuncs[] = {
{"GetPayload", LuaGetBody}, // {"GetPayload", LuaGetBody}, //
{"GetComment", LuaGetAssetComment}, // {"GetComment", LuaGetAssetComment}, //
{"GetVersion", LuaGetHttpVersion}, // {"GetVersion", LuaGetHttpVersion}, //
{"IsCompressed", LuaIsAssetCompressed}, //
{"GetLastModifiedTime", LuaGetAssetLastModifiedTime}, //
}; };
static const luaL_Reg kLuaLibs[] = { static const luaL_Reg kLuaLibs[] = {