]> source.dussan.org Git - rspamd.git/commitdiff
[Feature] Support sending given header multiple times in lua_http 2038/head
authorAndrew Lewis <nerf@judo.za.org>
Tue, 27 Feb 2018 14:43:34 +0000 (16:43 +0200)
committerAndrew Lewis <nerf@judo.za.org>
Tue, 27 Feb 2018 18:25:08 +0000 (20:25 +0200)
src/lua/lua_http.c

index e05c6360262fcacb718da4d95bb0a5bb346adfbe..2e331f57de1c979442f919c29b1d5ee77d2498c7 100644 (file)
@@ -316,16 +316,28 @@ static void
 lua_http_push_headers (lua_State *L, struct rspamd_http_message *msg)
 {
        const char *name, *value;
+       gint i, sz;
 
        lua_pushnil (L);
        while (lua_next (L, -2) != 0) {
 
                lua_pushvalue (L, -2);
                name = lua_tostring (L, -1);
-               value = lua_tostring (L, -2);
-
-               if (name != NULL && value != NULL) {
-                       rspamd_http_message_add_header (msg, name, value);
+               sz = rspamd_lua_table_size (L, -2);
+               if (sz != 0 && name != NULL) {
+                       for (i = 1; i <= sz ; i++) {
+                               lua_rawgeti (L, -2, i);
+                               value = lua_tostring (L, -1);
+                               if (value != NULL) {
+                                       rspamd_http_message_add_header (msg, name, value);
+                               }
+                               lua_pop (L, 1);
+                       }
+               } else {
+                       value = lua_tostring (L, -2);
+                       if (name != NULL && value != NULL) {
+                               rspamd_http_message_add_header (msg, name, value);
+                       }
                }
                lua_pop (L, 2);
        }