-- if the body is in memory record it as request.body,
-- otherwise if it is stored in a file record it as
-- request.body_file.
ngx.req.read_body()
request.body = ngx.req.get_body_data()
if not request.body then
local file = ngx.req.get_body_file()
if file then
request.body_file = file
end
end
...
-- if a body_file exists, ready it into memory
if request.body_file then
local fh, err = io.open(request.body_file, "rb")
if err then
ngx.status = ngx.HTTP_INTERNAL_SERVER_ERROR
ngx.log(ngx.ERR, "error reading request.body_file:", err)
return
end
request.body = fh:read("*all")
fh:close()
end