From: Vsevolod Stakhov Date: Tue, 7 Aug 2018 14:21:26 +0000 (+0100) Subject: [Feature] Support gathering HTTP body from fragments in lua_http X-Git-Tag: 1.8.0~300 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e11515be96af93e4a2f34cb4b7f260c11f439c9a;p=thirdparty%2Frspamd.git [Feature] Support gathering HTTP body from fragments in lua_http --- diff --git a/src/lua/lua_http.c b/src/lua/lua_http.c index 87244dd552..b3d4350f5f 100644 --- a/src/lua/lua_http.c +++ b/src/lua/lua_http.c @@ -553,6 +553,35 @@ lua_http_request (lua_State *L) if (t) { body = rspamd_fstring_new_init (t->start, t->len); } + else { + return luaL_error (L, "invalid body argument"); + } + } + else if (lua_type (L, -1) == LUA_TTABLE) { + body = rspamd_fstring_new (); + + for (lua_pushnil (L); lua_next (L, -2); lua_pop (L, 1)) { + if (lua_type (L, -1) == LUA_TSTRING) { + lua_body = lua_tolstring (L, -1, &bodylen); + body = rspamd_fstring_append (body, lua_body, bodylen); + } + else if (lua_type (L, -1) == LUA_TUSERDATA) { + t = lua_check_text (L, -1); + + if (t) { + body = rspamd_fstring_append (body, t->start, t->len); + } + else { + return luaL_error (L, "invalid body argument"); + } + } + else { + return luaL_error (L, "invalid body argument"); + } + } + } + else { + return luaL_error (L, "invalid body argument"); } lua_pop (L, 1);