From: Andrew Lewis Date: Tue, 27 Feb 2018 14:43:34 +0000 (+0200) Subject: [Feature] Support sending given header multiple times in lua_http X-Git-Tag: 1.7.0~103^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=cc566be99ecb93e703e627a43c5356cf893f9e4c;p=rspamd.git [Feature] Support sending given header multiple times in lua_http --- diff --git a/src/lua/lua_http.c b/src/lua/lua_http.c index e05c63602..2e331f57d 100644 --- a/src/lua/lua_http.c +++ b/src/lua/lua_http.c @@ -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); }