mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-09 11:20:30 +00:00
Add GetResponseBody to redbean to get access to generated response
This commit is contained in:
parent
6bb8b26d70
commit
e7957287da
2 changed files with 12 additions and 0 deletions
|
@ -1027,6 +1027,10 @@ FUNCTIONS
|
|||
IsPrivateIp or IsLoopbackIp return true. When multiple addresses
|
||||
are present in the header, the last/right-most address is used.
|
||||
|
||||
GetResponseBody() → str
|
||||
Returns the response message body if present or an empty string.
|
||||
Also returns an empty string during streaming.
|
||||
|
||||
GetClientAddr() → ip:uint32,port:uint16
|
||||
Returns client socket ip4 address and port, e.g. 0x01020304,31337
|
||||
would represent 1.2.3.4:31337. Please consider using GetRemoteAddr
|
||||
|
|
|
@ -4398,6 +4398,12 @@ static int LuaGetBody(lua_State *L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int LuaGetResponseBody(lua_State *L) {
|
||||
OnlyCallDuringRequest(L, "GetResponseBody");
|
||||
lua_pushlstring(L, content, contentlength);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int LuaGetHeader(lua_State *L) {
|
||||
int h;
|
||||
const char *key;
|
||||
|
@ -5054,6 +5060,7 @@ static const char *const kDontAutoComplete[] = {
|
|||
"GetPayload", // deprecated
|
||||
"GetPort", //
|
||||
"GetRemoteAddr", //
|
||||
"GetResponseBody", //
|
||||
"GetScheme", //
|
||||
"GetServerAddr", //
|
||||
"GetSslIdentity", //
|
||||
|
@ -5161,6 +5168,7 @@ static const luaL_Reg kLuaFuncs[] = {
|
|||
{"GetRandomBytes", LuaGetRandomBytes}, //
|
||||
{"GetRedbeanVersion", LuaGetRedbeanVersion}, //
|
||||
{"GetRemoteAddr", LuaGetRemoteAddr}, //
|
||||
{"GetResponseBody", LuaGetResponseBody}, //
|
||||
{"GetScheme", LuaGetScheme}, //
|
||||
{"GetServerAddr", LuaGetServerAddr}, //
|
||||
{"GetStatus", LuaGetStatus}, //
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue