Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(proxy-rewrite): when conf.headers are missing,conf.method can make effect #6300

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions apisix/plugins/proxy-rewrite.lua
Original file line number Diff line number Diff line change
Expand Up @@ -195,22 +195,20 @@ function _M.rewrite(conf, ctx)
ctx.var.upstream_uri = upstream_uri
end

if not conf.headers then
return
end

if not conf.headers_arr then
conf.headers_arr = {}
if conf.headers then
if not conf.headers_arr then
conf.headers_arr = {}

for field, value in pairs(conf.headers) do
core.table.insert_tail(conf.headers_arr, field, value)
for field, value in pairs(conf.headers) do
core.table.insert_tail(conf.headers_arr, field, value)
end
end
end

local field_cnt = #conf.headers_arr
for i = 1, field_cnt, 2 do
core.request.set_header(ctx, conf.headers_arr[i],
core.utils.resolve_var(conf.headers_arr[i+1], ctx.var))
local field_cnt = #conf.headers_arr
for i = 1, field_cnt, 2 do
core.request.set_header(ctx, conf.headers_arr[i],
core.utils.resolve_var(conf.headers_arr[i+1], ctx.var))
end
end

if conf.method then
Expand Down