]> source.dussan.org Git - rspamd.git/commitdiff
Add method to get all raw headers in LUA.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 3 Mar 2015 00:17:27 +0000 (00:17 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 3 Mar 2015 00:17:27 +0000 (00:17 +0000)
src/lua/lua_task.c

index 98083f187c26614ba031758f79a498c66d30be3d..60dfb7cf7dfe57ac05b889ee7368a1f6c22474a3 100644 (file)
@@ -222,6 +222,14 @@ function check_header_delimiter_tab(task, header_name)
 end
  */
 LUA_FUNCTION_DEF (task, get_header_full);
+
+/***
+ * @method task:get_raw_headers()
+ * Get all undecoded headers of a message as a string
+ * @reeturn {string} all raw headers for a message
+ */
+LUA_FUNCTION_DEF (task, get_raw_headers);
+
 /***
  * @method task:get_received_headers()
  * Returns a list of tables of parsed received headers. A tables returned have
@@ -447,6 +455,7 @@ static const struct luaL_reg tasklib_m[] = {
        LUA_INTERFACE_DEF (task, get_header),
        LUA_INTERFACE_DEF (task, get_header_raw),
        LUA_INTERFACE_DEF (task, get_header_full),
+       LUA_INTERFACE_DEF (task, get_raw_headers),
        LUA_INTERFACE_DEF (task, get_received_headers),
        LUA_INTERFACE_DEF (task, get_resolver),
        LUA_INTERFACE_DEF (task, inc_dns_req),
@@ -1159,6 +1168,21 @@ lua_task_get_header_raw (lua_State * L)
        return lua_task_get_header_common (L, FALSE, TRUE);
 }
 
+static gint
+lua_task_get_raw_headers (lua_State *L)
+{
+       struct rspamd_task *task = lua_check_task (L, 1);
+
+       if (task) {
+               lua_pushstring (L, task->raw_headers_str);
+       }
+       else {
+               lua_pushnil (L);
+       }
+
+       return 1;
+}
+
 static gint
 lua_task_get_received_headers (lua_State * L)
 {