LUA_FUNCTION_DEF (task, get_text_parts);
LUA_FUNCTION_DEF (task, get_parts);
LUA_FUNCTION_DEF (task, get_header);
+LUA_FUNCTION_DEF (task, get_header_raw);
LUA_FUNCTION_DEF (task, get_header_full);
LUA_FUNCTION_DEF (task, get_received_headers);
LUA_FUNCTION_DEF (task, get_resolver);
LUA_INTERFACE_DEF (task, get_text_parts),
LUA_INTERFACE_DEF (task, get_parts),
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_received_headers),
LUA_INTERFACE_DEF (task, get_resolver),
struct rspamd_task *task,
const gchar *name,
gboolean strong,
- gboolean full)
+ gboolean full,
+ gboolean raw)
{
struct raw_header *rh;
gint i = 1;
+ const gchar *val;
lua_newtable (L);
rh = g_hash_table_lookup (task->raw_headers, name);
rh = rh->next;
}
else {
- if (rh->decoded) {
- lua_pushstring (L, rh->decoded);
+ if (raw) {
+ val = rh->decoded;
+ }
+ else {
+ val = rh->value;
+ }
+ if (val) {
+ lua_pushstring (L, val);
}
else {
lua_pushnil (L);
}
static gint
-lua_task_get_header_full (lua_State * L)
+lua_task_get_header_common (lua_State *L, gboolean full, gboolean raw)
{
gboolean strong = FALSE;
struct rspamd_task *task = lua_check_task (L);
if (lua_gettop (L) == 3) {
strong = lua_toboolean (L, 3);
}
- return lua_task_push_header (L, task, name, strong, TRUE);
+ return lua_task_push_header (L, task, name, strong, full, raw);
}
lua_pushnil (L);
return 1;
}
static gint
-lua_task_get_header (lua_State * L)
+lua_task_get_header_full (lua_State * L)
{
- gboolean strong = FALSE;
- struct rspamd_task *task = lua_check_task (L);
- const gchar *name;
+ return lua_task_get_header_common (L, TRUE, TRUE);
+}
- name = luaL_checkstring (L, 2);
+static gint
+lua_task_get_header (lua_State * L)
+{
+ return lua_task_get_header_common (L, FALSE, FALSE);
+}
- if (name && task) {
- if (lua_gettop (L) == 3) {
- strong = lua_toboolean (L, 3);
- }
- return lua_task_push_header (L, task, name, strong, FALSE);
- }
- lua_pushnil (L);
- return 1;
+static gint
+lua_task_get_header_raw (lua_State * L)
+{
+ return lua_task_get_header_common (L, FALSE, TRUE);
}
static gint