You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by sp...@apache.org on 2022/09/09 05:21:49 UTC
[apisix] branch master updated: fix: response-rewrite plugin might cause Apache AIPSIX hanging (#7836)
This is an automated email from the ASF dual-hosted git repository.
spacewander pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git
The following commit(s) were added to refs/heads/master by this push:
new bd9333722 fix: response-rewrite plugin might cause Apache AIPSIX hanging (#7836)
bd9333722 is described below
commit bd93337220e842afecc3a4dd3f55c7ecdb65b5f5
Author: chengxiaolan <30...@users.noreply.github.com>
AuthorDate: Fri Sep 9 13:21:41 2022 +0800
fix: response-rewrite plugin might cause Apache AIPSIX hanging (#7836)
---
apisix/plugins/response-rewrite.lua | 4 +---
t/plugin/response-rewrite.t | 47 +++++++++++++++++++++++++++++++++++++
2 files changed, 48 insertions(+), 3 deletions(-)
diff --git a/apisix/plugins/response-rewrite.lua b/apisix/plugins/response-rewrite.lua
index c07924253..4c3487da0 100644
--- a/apisix/plugins/response-rewrite.lua
+++ b/apisix/plugins/response-rewrite.lua
@@ -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
diff --git a/t/plugin/response-rewrite.t b/t/plugin/response-rewrite.t
index 53b3d1d10..d9283e3fe 100644
--- a/t/plugin/response-rewrite.t
+++ b/t/plugin/response-rewrite.t
@@ -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]