aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-10-07 16:38:12 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-10-07 16:38:12 +0100
commit05e5995e153e06943499b0b8bc09346cf3d302fe (patch)
tree77121c097d270b8d12e19a8c7438c12fd4b997a3 /src
parent8c9d21338b42fc6671b514f202f664050d3c4174 (diff)
downloadrspamd-05e5995e153e06943499b0b8bc09346cf3d302fe.tar.gz
rspamd-05e5995e153e06943499b0b8bc09346cf3d302fe.zip
Fix headers operation in lua_task.
Diffstat (limited to 'src')
-rw-r--r--src/lua/lua_task.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c
index 4ef772a5c..3bc40efe4 100644
--- a/src/lua/lua_task.c
+++ b/src/lua/lua_task.c
@@ -963,7 +963,7 @@ lua_task_get_parts (lua_State * L)
static gint
lua_task_get_request_header (lua_State *L)
{
- GString *hdr, srch;
+ rspamd_ftok_t *hdr, srch;
struct rspamd_task *task = lua_check_task (L, 1);
const gchar *s;
struct rspamd_lua_text *t;
@@ -972,7 +972,7 @@ lua_task_get_request_header (lua_State *L)
s = luaL_checklstring (L, 2, &len);
if (s) {
- srch.str = (gchar *)s;
+ srch.begin = (gchar *)s;
srch.len = len;
hdr = g_hash_table_lookup (task->request_headers, &srch);
@@ -980,7 +980,7 @@ lua_task_get_request_header (lua_State *L)
if (hdr) {
t = lua_newuserdata (L, sizeof (*t));
rspamd_lua_setclass (L, "rspamd{text}", -1);
- t->start = hdr->str;
+ t->start = hdr->begin;
t->len = hdr->len;
t->own = FALSE;
@@ -997,8 +997,9 @@ lua_task_set_request_header (lua_State *L)
{
struct rspamd_task *task = lua_check_task (L, 1);
const gchar *s, *v = NULL;
+ rspamd_fstring_t *buf;
struct rspamd_lua_text *t;
- GString *hdr, srch, *new_name;
+ rspamd_ftok_t *hdr, srch, *new_name;
gsize len, vlen;
s = luaL_checklstring (L, 2, &len);
@@ -1017,19 +1018,22 @@ lua_task_set_request_header (lua_State *L)
}
if (v != NULL) {
- srch.str = (gchar *)s;
+ srch.begin = (gchar *)s;
srch.len = len;
hdr = g_hash_table_lookup (task->request_headers, &srch);
- if (hdr) {
+ if (!hdr) {
new_name = &srch;
}
else {
/* Not found, need to allocate */
- new_name = g_string_new_len (srch.str, srch.len);
+ buf = rspamd_fstring_new_init (srch.begin, srch.len);
+ new_name = rspamd_ftok_map (buf);
}
- hdr = g_string_new_len (v, vlen);
+
+ buf = rspamd_fstring_new_init (v, vlen);
+ hdr = rspamd_ftok_map (buf);
/* This does not destroy key if it exists */
g_hash_table_insert (task->request_headers, new_name, hdr);