Skip to content

Commit

Permalink
[Minor] Honor more redirect 3xx codes
Browse files Browse the repository at this point in the history
Issue: #4395
  • Loading branch information
vstakhov committed Feb 25, 2023
1 parent 7355dc0 commit d1795df
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/plugins/lua/url_redirector.lua
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,14 @@ local function resolve_cached(task, orig_url, url, key, ntries)
return
end

local redirection_codes = {
[301] = true, -- moved permanently
[302] = true, -- found
[303] = true, -- see other
[307] = true, -- temporary redirect
[308] = true, -- permanent redirect
}

local function http_callback(err, code, _, headers)
if err then
rspamd_logger.infox(task, 'found redirect error from %s to %s, err message: %s',
Expand All @@ -187,7 +195,7 @@ local function resolve_cached(task, orig_url, url, key, ntries)

cache_url(task, orig_url, url, key)

elseif code == 301 or code == 302 then
elseif redirection_codes[code] then
local loc = headers['location']
local redir_url
if loc then
Expand Down

0 comments on commit d1795df

Please sign in to comment.