mcdullbloom opened a new issue, #10379:
URL: https://github.com/apache/apisix/issues/10379
### Description
the action of set max_body_size is invalid when a handler in access phase
has read request body, which is running before access_by_lua.And we can't just
put access_by_lua handler before that handler, since access_by_lua is the major
phase of apisix.
client-control.lua
```lua
-- then check it when reading the body
local ok, err =
apisix_ngx_client.set_client_max_body_size(conf.max_body_size)
if not ok then
core.log.error("failed to set client max body size: ", err)
return 503
end
```
```c
ngx_int_t
ngx_http_read_client_request_body(ngx_http_request_t *r,
ngx_http_client_body_handler_pt post_handler){
……
if (r != r->main || r->request_body || r->discard_body) { // request
body will be read only once totallly
r->request_body_no_buffering = 0;
post_handler(r);
return NGX_OK;
}
#if (NGX_HTTP_APISIX)
if (ngx_http_apisix_delay_client_max_body_check(r)) {
off_t max_body_size = ngx_http_apisix_client_max_body_size(r); //
max_body_size has not been set by plugin when the handler of third-party module
is called
if (r->headers_in.content_length_n != -1
&& max_body_size
&& max_body_size < r->headers_in.content_length_n)
{
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
"client intended to send too large body: %O bytes",
r->headers_in.content_length_n);
r->expect_tested = 1;
rc = NGX_HTTP_REQUEST_ENTITY_TOO_LARGE;
goto done;
}
}
……
```
### Environment
- APISIX version (run `apisix version`):
- Operating system (run `uname -a`):
- OpenResty / Nginx version (run `openresty -V` or `nginx -V`): 1.19.3
- etcd version, if relevant (run `curl
http://127.0.0.1:9090/v1/server_info`):
- APISIX Dashboard version, if relevant:
- Plugin runner version, for issues related to plugin runners:
- LuaRocks version, for installation issues (run `luarocks --version`):
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]