Browse Source

Merge pull request #4595 from lbahtarliev/master

[Feature] Add ICAP Content-Type and Filename from TODO List
tags/3.7.1
Vsevolod Stakhov 9 months ago
parent
commit
054e08b328
No account linked to committer's email address
2 changed files with 10 additions and 4 deletions
  1. 8
    2
      lualib/lua_scanners/icap.lua
  2. 2
    2
      src/plugins/lua/external_services.lua

+ 8
- 2
lualib/lua_scanners/icap.lua View File

@@ -240,10 +240,16 @@ local function icap_check(task, content, digest, rule, maybe_part)

local function get_req_headers()

local in_client_ip = task:get_from_ip()
local req_hlen = 2
table.insert(req_headers, string.format('GET %s HTTP/1.0\r\n', rule.req_fake_url))
table.insert(req_headers, string.format('Date: %s\r\n', rspamd_util.time_to_string(rspamd_util.get_time())))
--table.insert(http_headers, string.format('Content-Type: %s\r\n', 'text/html'))
if maybe_part then
table.insert(req_headers, string.format('GET http://%s/%s HTTP/1.0\r\n', in_client_ip, maybe_part:get_filename()))
table.insert(http_headers, string.format('Content-Type: %s/%s\r\n', maybe_part:get_detected_type()))
else
table.insert(req_headers, string.format('GET %s HTTP/1.0\r\n', rule.req_fake_url))
table.insert(http_headers, string.format('Content-Type: application/octet-stream\r\n'))
end
if rule.user_agent ~= "none" then
table.insert(req_headers, string.format("User-Agent: %s\r\n", rule.user_agent))
end

+ 2
- 2
src/plugins/lua/external_services.lua View File

@@ -181,12 +181,12 @@ local function add_scanner_rule(sym, opts)
fun.each(function(p)
local content = p:get_content()
if content and #content > 0 then
cfg.check(task, content, p:get_digest(), rule)
cfg.check(task, content, p:get_digest(), rule, p)
end
end, common.check_parts_match(task, rule))

else
cfg.check(task, task:get_content(), task:get_digest(), rule)
cfg.check(task, task:get_content(), task:get_digest(), rule, nil)
end
end


Loading…
Cancel
Save