aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2011-05-24 18:07:28 +0400
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2011-05-24 18:07:28 +0400
commit3b0487ad7ca4227133c495f26b3a6ee6a08a5831 (patch)
tree35d229b9090805cc276b8bbe3e1d55dfb27f6566 /src/lua
parentc594689abf8dad487c16615d451f11021ac8de68 (diff)
downloadrspamd-3b0487ad7ca4227133c495f26b3a6ee6a08a5831.tar.gz
rspamd-3b0487ad7ca4227133c495f26b3a6ee6a08a5831.zip
* Fix error in raw headers parsing
* Improve speed of raw headers access
Diffstat (limited to 'src/lua')
-rw-r--r--src/lua/lua_task.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c
index 1011612aa..2ab56b29c 100644
--- a/src/lua/lua_task.c
+++ b/src/lua/lua_task.c
@@ -313,7 +313,7 @@ lua_task_get_raw_headers (lua_State * L)
struct worker_task *task = lua_check_task (L);
if (task) {
- lua_pushstring (L, task->raw_headers);
+ lua_pushstring (L, task->raw_headers_str);
}
else {
lua_pushnil (L);
@@ -326,7 +326,6 @@ static gint
lua_task_get_raw_header_common (lua_State * L, gboolean strong)
{
struct worker_task *task = lua_check_task (L);
- GList *cur;
struct raw_header *rh;
gint i = 1;
const gchar *name;
@@ -338,23 +337,27 @@ lua_task_get_raw_header_common (lua_State * L, gboolean strong)
return 1;
}
lua_newtable (L);
- cur = g_list_first (task->raw_headers_list);
- while (cur) {
- rh = cur->data;
+ rh = g_hash_table_lookup (task->raw_headers, name);
+
+ if (rh == NULL) {
+ return 1;
+ }
+
+ while (rh) {
if (rh->name == NULL) {
- cur = g_list_next (cur);
+ rh = rh->next;
continue;
}
/* Check case sensivity */
if (strong) {
if (strcmp (rh->name, name) != 0) {
- cur = g_list_next (cur);
+ rh = rh->next;
continue;
}
}
else {
if (g_ascii_strcasecmp (rh->name, name) != 0) {
- cur = g_list_next (cur);
+ rh = rh->next;
continue;
}
}
@@ -371,7 +374,7 @@ lua_task_get_raw_header_common (lua_State * L, gboolean strong)
lua_set_table_index (L, "separator", rh->separator);
lua_rawseti (L, -2, i++);
/* Process next element */
- cur = g_list_next (cur);
+ rh = rh->next;
}
}
else {