leafo / lapis

A web framework for Lua and OpenResty written in MoonScript
http://leafo.net/lapis/
MIT License
3.12k stars 247 forks source link

request:read_body_as_string() fails if body was buffered to a temporary file with nginx #784

Open jprjr opened 5 months ago

jprjr commented 5 months ago

Hi there - I noticed that if a larger request is buffered to a file, read_body_as_string doesn't return any data.

The lapis request object appears to only call ngx.req.get_body_data() which will return nil if the request was buffered to disk. In the OpenResty docs they recommend trying ngx.req.get_body_data(), then falling back to ngx.req.get_body_file()