kong
kong copied to clipboard
fix(plugins/request-size-limiting): Check the file size when the request body buffered to a temporary file
Summary
Firstly enable request-size-limiting plugin with below config
plugins:
- config:
allowed_payload_size: 512
require_content_length: false
size_unit: kilobytes
enabled: true
name: request-size-limiting
When client send request without content-length and request body chunked with Transfer-Encoding, then kong.request.get_raw_body() become nil, and request-size-limiting plugin do not work anymore and return 200 directly.
Below curl command could trigger the error:
dd if=/dev/urandom of=1m.dat bs=1m count=1
curl -v --data-binary @1m.dat http://kong:8000/test -H "Content-Length:" -H "Transfer-Encoding: chunked"
This PR will check the file size when the request body buffered to a temporary file. Then request-size-limiting plugin still able to get the request body size and work as expected.
Checklist
- [x] The Pull Request has tests
- [x] A changelog file has been created under
changelog/unreleased/kongorskip-changeloglabel added on PR if changelog is unnecessary. README.md - [ ] There is a user-facing docs PR against https://github.com/Kong/docs.konghq.com - PUT DOCS PR HERE
Issue reference
Fix #FTI-6034