ziyou434 commented on issue #3062:
URL: https://github.com/apache/apisix/issues/3062#issuecomment-747150775
```lua
function _M.get_body(max_size, ctx)
-- TODO: improve the check with set client_max_body dynamically
-- which requires to change Nginx source code
if max_size then
local var = ctx and ctx.var or ngx.var
local content_length = tonumber(var.http_content_length)
if content_length then
local ok, err = check_size(content_length, max_size)
if not ok then
-- When client_max_body_size is exceeded, Nginx will set
r->expect_tested = 1 to
-- avoid sending the 100 CONTINUE.
-- We use trick below to imitate this behavior.
if test_expect(var) then
clear_header("expect")
end
return nil, err
end
end
end
req_read_body()
local req_body = req_get_body_data()
if req_body then
local ok, err = check_size(#req_body, max_size)
if not ok then
return nil, err
end
return req_body
end
local file_name = req_get_body_file()
if not file_name then
return nil
end
log.info("attempt to read body from file: ", file_name)
if max_size then
local size, err = lfs.attributes (file_name, "size")
if not size then
return nil, err
end
local ok, err = check_size(size, max_size)
if not ok then
return nil, err
end
end
local req_body, err = get_file(file_name)
return req_body, err
end
```
In my opinion, ngx.req.read_body() can't handle 40,000 characters.
I guess ngx.req_get_body_file() takes effect, but I can't find
client_body_buffer_size in nginx.conf .
Is the buffer not large enough to display only 12,000 characters ?
----------------------------------------------------------------
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]