From: Vsevolod Stakhov Date: Tue, 7 Apr 2015 21:45:09 +0000 (+0100) Subject: Use rspamd{text} in lua_http. X-Git-Tag: 0.9.0~300 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=0fce52b8d5ead7d0964b38ffdf44ba85f257f866;p=rspamd.git Use rspamd{text} in lua_http. --- diff --git a/src/lua/lua_http.c b/src/lua/lua_http.c index 07c0d7d98..9e1082dcf 100644 --- a/src/lua/lua_http.c +++ b/src/lua/lua_http.c @@ -228,6 +228,7 @@ lua_http_request (lua_State *L) struct lua_http_cbdata *cbd; struct rspamd_dns_resolver *resolver; struct rspamd_async_session *session; + struct rspamd_lua_text *t; gdouble timeout = default_http_timeout; if (lua_gettop (L) >= 2) { @@ -335,6 +336,16 @@ lua_http_request (lua_State *L) if (lua_type (L, -1) == LUA_TSTRING) { msg->body = g_string_new (lua_tostring (L, -1)); } + else if (lua_type (L, -1) == LUA_TUSERDATA) { + t = lua_check_text (L, -1); + if (t) { + /* XXX: is it safe ? */ + msg->body = g_string_new (NULL); + msg->body->str = (gchar *)t->start; + msg->body->len = t->len; + } + } + lua_pop (L, 1); } else {