Skip to content

bug: when use response rewrite plugin, scenarios that return an empty body cannot be supported #7722

Description

@Hazel6869

Current Behavior

➜ example git:(master) ✗ curl http://127.0.0.1:9080/apisix/admin/routes/1
-H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
"methods": ["GET"],
"uri": "/get",
"plugins": {
"response-rewrite": {
"body_base64":false,
"body": "",
"headers": {
"X-Server-id": 3,
"X-Server-status": "on",
"X-Server-balancer_addr": "$balancer_ip:$balancer_port"
},
"vars":[
[ "status","==",200 ]
]
}
},
"upstream": {
"type": "roundrobin",
"nodes": {
"httpbin.org": 1
}
}
}'

➜ example git:(master) ✗ curl -X GET -i http://127.0.0.1:9080/get
HTTP/1.1 502 Bad Gateway
Connection: keep-alive
Keep-Alive: timeout=4
Proxy-Connection: keep-alive
Content-Length: 0

Expected Behavior

➜ example git:(master) ✗ curl -X GET -i http://127.0.0.1:9080/get
HTTP/1.1 200 OK
Transfer-Encoding: chunked
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Type: application/json
Date: Wed, 17 Aug 2022 08:44:10 GMT
Keep-Alive: timeout=4
Proxy-Connection: keep-alive
Server: APISIX/2.15.0
X-Server-Balancer-Addr: 34.227.213.82:80
X-Server-Id: 3
X-Server-Status: on

Error Logs

No response

Steps to Reproduce

I will fix this

Environment

  • APISIX version (run apisix version): version 2.15.0
  • Operating system (run uname -a): Linux lan 5.15.0-41-generic doc: add qq group. #44-Ubuntu SMP Wed Jun 22 14:20:53 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
  • OpenResty / Nginx version (run openresty -V or nginx -V): ginx version: openresty/1.21.4.1
    built with OpenSSL 1.1.1n 15 Mar 2022
  • etcd version, if relevant (run ):
  • APISIX Dashboard version, if relevant:
  • Plugin runner version, for issues related to plugin runners:
  • LuaRocks version, for installation issues (run luarocks --version):

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions