fix: always rewrite redirects regardless of content-type

This commit is contained in:
Iain Learmonth 2025-05-05 11:20:20 +01:00
parent d6e7ce13b0
commit 041891dc9a

View file

@ -15,13 +15,12 @@ if ngx.header["Content-Type"] then
content_type:find("application/vnd.mpegurl") or content_type:find("application/vnd.mpegurl") or
content_type:find("application/x-mpegurl") then content_type:find("application/x-mpegurl") then
ngx.ctx.rewriting = true ngx.ctx.rewriting = true
ngx.header["Content-Length"] = nil ngx.header["Content-Length"] = nil -- We're rewriting the body so this has the wrong value if set
end end
end end
if ngx.header["Location"] then if ngx.header["Location"] then
local pool_map = ngx.ctx.jasima_pool_map if ngx.ctx.jasima_pool_map then
if ngx.ctx.rewriting and pool_map then
local location = ngx.header["Location"] local location = ngx.header["Location"]
ngx.header["Location"] = location:gsub("//([a-zA-Z0-9%.%-]+%.[a-zA-Z0-9]+)/", utils.get_mirror) ngx.header["Location"] = location:gsub("//([a-zA-Z0-9%.%-]+%.[a-zA-Z0-9]+)/", utils.get_mirror)
end end