我在body_filter_by_lua_block中修改了ngx.arg[1]的值,日志打印显示也是修改成功了,但是curl访问却没有变化,代码如下:
location /test/ {
body_filter_by_lua_block {
if ngx.arg[2] == true then
local content_range = ngx.header.content_range
if content_range then
local m = ngx.re.match(content_range, "bytes (\\d+)-(\\d+)/(\\d+)")
if m then
local m1 = tonumber(m[1])
local m2 = tonumber(m[2])
local m3 = tonumber(m[3])
if m2 >= m3 - 32 then
local s = ngx.md5(math.random())
if m1 >= m3 - 32 then
ngx.arg[1] = string.sub(s, 1, string.len(ngx.arg[1]))
else
ngx.arg[1] = string.sub(ngx.arg[1], 1, -1 - (33 + m2 - m3)) .. string.sub(s, 1, m2 - m3)
end
end
end
else
ngx.arg[1] = string.sub(ngx.arg[1], 1, -33) .. ngx.md5(math.random())
end
end
print(string.gsub(ngx.arg[1],"(.)",function (x) return string.format("%02X ",string.byte(x)) end))
}
proxy_pass http://test2/;
}