]> source.dussan.org Git - rspamd.git/commitdiff
Use rspamd{text} in lua_http.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 7 Apr 2015 21:45:09 +0000 (22:45 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 7 Apr 2015 21:45:09 +0000 (22:45 +0100)
src/lua/lua_http.c

index 07c0d7d98612795c4bbd611a0e6b28a5454009c8..9e1082dcf461edb6f143802b28551aecaa6ab738 100644 (file)
@@ -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 {