diaosj opened a new issue #3552:
URL: https://github.com/apache/apisix/issues/3552
### Issue description
I wrote a plugin to deal with the incoming request, then forwarded it to
upstream servers. The simplified logic is like this:
```lua
local req_body, _ = core.request.get_body()
...
local decoded, _ = core.json.decode(req_body)
...
req_body, _ = core.json.encode(decoded)
core.log.warn("RequestId: ", ctx.var.request_id, " ctx.var.http_x_tc_action:
", ctx.var.http_x_tc_action, " req_body: ", req_body)
-- set body
ngx.req.set_body_data(req_body)
```
When the request is about 20k,the upstream server can't decode received
data. I checked the APISIX log and found these two lines:
```
2021/02/07 15:35:30 [warn] 48#48: *110236 a client request body is buffered
to a temporary file /usr/local/apisix/client_body_temp/0000000007, client:
172.17.48.15, server: , request: "POST /gateway?cmd=SaveFlow HTTP/1.1", host:
"121.4.203.92"
2021/02/07 15:35:30 [warn] 48#48: *110236 [lua] rewrite-ti.lua:152:
phase_func(): RequestId: e00dd516-e59a-43c2-90b4-a94ae6b93d76
ctx.var.http_x_tc_action: SaveFlow req_body:
{"RequestId":"e00dd516-e59a-43c2-90b4-a94ae6b93d76", <xxx, too long>
```
I know that the default `client_body_buffer_size` value is 16k. The
request's size exceeds this limit. So the request is buffered to a temp file.
When printed to log, the content is cut off. I wonder which step caused this
unexpected behavior.
### Environment
* apisix version (cmd: `apisix version`): 2.1
* OS (cmd: `uname -a`): Linux
* OpenResty / Nginx version (cmd: `nginx -V` or `openresty -V`):
openresty/1.19.3.1
* etcd version, if have (cmd: run `curl
http://127.0.0.1:9090/v1/server_info` to get the info from server-info API):
* apisix-dashboard version, if have:
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]