Skip to content

Commit

Permalink
Revert "fix(request-transformer): respect letter case of rename heade…
Browse files Browse the repository at this point in the history
…rs' new names (#12244)"

This reverts commit 3015421.
  • Loading branch information
StarlightIbuki authored and windmgc committed Jan 5, 2024
1 parent 9317986 commit c3abb6a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.

This file was deleted.

2 changes: 1 addition & 1 deletion kong/plugins/request-transformer/access.lua
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ local function transform_headers(conf, template_env)
old_name = old_name:lower()
local value = headers[old_name]
if value then
headers[new_name] = value
headers[new_name:lower()] = value
headers[old_name] = nil
headers_to_remove[old_name] = true
end
Expand Down
10 changes: 5 additions & 5 deletions spec/03-plugins/36-request-transformer/02-access_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ describe("Plugin: request-transformer(access) [#" .. strategy .. "]", function()
name = "request-transformer",
config = {
rename = {
headers = {"x-to-rename:X-Is-Renamed"},
headers = {"x-to-rename:x-is-renamed"},
querystring = {"originalparam:renamedparam"},
body = {"originalparam:renamedparam"}
}
Expand Down Expand Up @@ -712,7 +712,7 @@ describe("Plugin: request-transformer(access) [#" .. strategy .. "]", function()
assert.response(r).has.status(200)
assert.response(r).has.jsonbody()
assert.request(r).has.no.header("x-to-rename")
assert.request(r).has.header("X-Is-Renamed")
assert.request(r).has.header("x-is-renamed")
assert.request(r).has.header("x-another-header")
end)
it("does not add as new header if header does not exist", function()
Expand All @@ -738,13 +738,13 @@ describe("Plugin: request-transformer(access) [#" .. strategy .. "]", function()
headers = {
host = "test9.test",
["x-to-rename"] = "new-result",
["X-Is-Renamed"] = "old-result",
["x-is-renamed"] = "old-result",
}
})
assert.response(r).has.status(200)
assert.response(r).has.jsonbody()
assert.request(r).has.no.header("x-to-rename")
local h_is_renamed = assert.request(r).has.header("X-Is-Renamed")
local h_is_renamed = assert.request(r).has.header("x-is-renamed")
assert.equals("new-result", h_is_renamed)
end)
for _, seq in ipairs({ 1, 2, 3, 4, 5, 6}) do
Expand All @@ -761,7 +761,7 @@ describe("Plugin: request-transformer(access) [#" .. strategy .. "]", function()
assert.response(r).has.status(200)
assert.response(r).has.jsonbody()
assert.request(r).has.no.header("x-to-rename")
local h_is_renamed = assert.request(r).has.header("X-Is-Renamed")
local h_is_renamed = assert.request(r).has.header("x-is-renamed")
assert.equals("new-result", h_is_renamed)
end)
end
Expand Down

0 comments on commit c3abb6a

Please sign in to comment.