summaryrefslogtreecommitdiffstats
path: root/lualib
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2021-10-07 09:45:03 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2021-10-07 09:45:03 +0100
commit0dc617cb0eab563e9b248b3b7d029b56dbf517d6 (patch)
tree73a59f4d853f0cb78da27d5d1010c273de285818 /lualib
parent030873c19f9c15d37e52243962abbdb85b86a245 (diff)
downloadrspamd-0dc617cb0eab563e9b248b3b7d029b56dbf517d6.tar.gz
rspamd-0dc617cb0eab563e9b248b3b7d029b56dbf517d6.zip
[Minor] Lua_mime: Allow to add headers in specific order
Diffstat (limited to 'lualib')
-rw-r--r--lualib/lua_mime.lua14
1 files changed, 13 insertions, 1 deletions
diff --git a/lualib/lua_mime.lua b/lualib/lua_mime.lua
index 72190b19e..ad38d3c32 100644
--- a/lualib/lua_mime.lua
+++ b/lualib/lua_mime.lua
@@ -519,7 +519,8 @@ exports.modify_headers = function(task, hdr_alterations)
local remove = hdr_alterations.remove or {}
local hdr_flattened = {} -- For C API
- for hname,hdr in pairs(add) do
+
+ local function flatten_add_header(hname, hdr)
if not hdr_flattened[hname] then
hdr_flattened[hname] = {add = {}}
end
@@ -532,6 +533,17 @@ exports.modify_headers = function(task, hdr_alterations)
end
end
end
+ if hdr_alterations.order then
+ -- Get headers alterations ordered
+ for _,hname in ipairs(hdr_alterations.order) do
+ flatten_add_header(hname, add[hname])
+ end
+ else
+ for hname,hdr in pairs(add) do
+ flatten_add_header(hname, hdr)
+ end
+ end
+
for hname,hdr in pairs(remove) do
if not hdr_flattened[hname] then