Skip to content

Commit

Permalink
fix: response-rewrite plugin might cause Apache AIPSIX hanging (apach…
Browse files Browse the repository at this point in the history
  • Loading branch information
Hazel6869 authored and Liu-Junlin committed Nov 4, 2022
1 parent 18f4266 commit d6e437f
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 3 deletions.
4 changes: 1 addition & 3 deletions apisix/plugins/response-rewrite.lua
Original file line number Diff line number Diff line change
Expand Up @@ -276,14 +276,12 @@ function _M.body_filter(conf, ctx)
end

if conf.body then

ngx.arg[2] = true
if conf.body_base64 then
ngx.arg[1] = ngx.decode_base64(conf.body)
else
ngx.arg[1] = conf.body
end

ngx.arg[2] = true
end
end

Expand Down
47 changes: 47 additions & 0 deletions t/plugin/response-rewrite.t
Original file line number Diff line number Diff line change
Expand Up @@ -699,3 +699,50 @@ X-A: 127.0.0.1
X-B: from 127.0.0.1 to 127.0.0.1:1980
--- no_error_log
[error]



=== TEST 25: set empty body
--- 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": {
"body": ""
}
},
"upstream": {
"nodes": {
"127.0.0.1:1980": 1
},
"type": "roundrobin"
},
"uri": "/hello"
}]]
)

if code >= 300 then
ngx.status = code
end
ngx.say(body)
}
}
--- request
GET /t
--- response_body
passed
--- no_error_log
[error]



=== TEST 26: hit set empty body
--- request
GET /hello
--- response_body
--- no_error_log
[error]

0 comments on commit d6e437f

Please sign in to comment.