From 0fce52b8d5ead7d0964b38ffdf44ba85f257f866 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 7 Apr 2015 22:45:09 +0100 Subject: [PATCH] Use rspamd{text} in lua_http. --- src/lua/lua_http.c | 11 +++++++++++ 1 file changed, 11 insertions(+) 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 { -- 2.39.5