From d60e855870e0902af6cb82eb5854df04a5afd6fd Mon Sep 17 00:00:00 2001 From: Paul Kulchenko Date: Sun, 31 Oct 2021 16:44:29 -0700 Subject: [PATCH] Rename redbean Lua function GetPayload to GetBody This breaking change improves consistency with RFC 7230 terminology. --- tool/net/help.txt | 7 +++---- tool/net/redbean.c | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/tool/net/help.txt b/tool/net/help.txt index 6ef03ad5f..3bc82887b 100644 --- a/tool/net/help.txt +++ b/tool/net/help.txt @@ -604,6 +604,9 @@ FUNCTIONS Returns byte size of uncompressed contents of ZIP asset (or local file if the -D flag is used) + GetBody() → str + Returns the request message body if present or an empty string. + GetCookie(name:str) → str Returns cookie value. @@ -716,10 +719,6 @@ FUNCTIONS GetTime() → seconds:number Returns current time as a UNIX timestamp with 0.0001s precision. - GetPayload() → str - Returns the request message payload, or empty string if there - isn't one. - GetUrl() → str Returns the effective Request-URL as an ASCII string, where illegal characters or UTF-8 is guaranteed to be percent encoded, diff --git a/tool/net/redbean.c b/tool/net/redbean.c index d6d6832e7..583e54f7a 100644 --- a/tool/net/redbean.c +++ b/tool/net/redbean.c @@ -4097,7 +4097,7 @@ static int LuaParseHttpDateTime(lua_State *L) { return 1; } -static int LuaGetPayload(lua_State *L) { +static int LuaGetBody(lua_State *L) { lua_pushlstring(L, inbuf.p + hdrsize, payloadlength); return 1; } @@ -5328,6 +5328,7 @@ static const luaL_Reg kLuaFuncs[] = { {"GetAssetComment", LuaGetAssetComment}, // {"GetAssetMode", LuaGetAssetMode}, // {"GetAssetSize", LuaGetAssetSize}, // + {"GetBody", LuaGetBody}, // {"GetClientAddr", LuaGetClientAddr}, // {"GetCookie", LuaGetCookie}, // {"GetDate", LuaGetDate}, // @@ -5347,7 +5348,6 @@ static const luaL_Reg kLuaFuncs[] = { {"GetParams", LuaGetParams}, // {"GetPass", LuaGetPass}, // {"GetPath", LuaGetPath}, // - {"GetPayload", LuaGetPayload}, // {"GetPort", LuaGetPort}, // {"GetRandomBytes", LuaGetRandomBytes}, // {"GetRedbeanVersion", LuaGetRedbeanVersion}, //