Skip to content

Commit

Permalink
fix: response-rewrite plugin can't add only one character (apache#9372)
Browse files Browse the repository at this point in the history
  • Loading branch information
LiteSun authored and AlinsRan committed Jun 25, 2023
1 parent dd0ae22 commit bb3af5f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion apisix/plugins/response-rewrite.lua
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ local schema = {
items = {
type = "string",
-- "Set-Cookie: <cookie-name>=<cookie-value>; Max-Age=<number>"
pattern = "^[^:]+:[^:]+[^/]$"
pattern = "^[^:]+:[^:]*[^/]$"
}
},
set = {
Expand Down
37 changes: 37 additions & 0 deletions t/plugin/response-rewrite.t
Original file line number Diff line number Diff line change
Expand Up @@ -696,3 +696,40 @@ passed
--- request
GET /hello
--- response_body



=== TEST 27: test add header with one word
--- config
location /t {
content_by_lua_block {
local t = require("lib.test_admin").test
local code, body = t('/apisix/admin/routes/1',
ngx.HTTP_PUT,
[[{
"plugins": {
"response-rewrite": {
"headers": {
"add": [
"X-Server-test:a"
]
}
}
},
"upstream": {
"nodes": {
"127.0.0.1:1980": 1
},
"type": "roundrobin"
},
"uris": ["/hello"]
}]]
)

ngx.say(body)
}
}
--- request
GET /t
--- response_body
passed

0 comments on commit bb3af5f

Please sign in to comment.