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;
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);
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;
{
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);
}
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);