Hi there!
Is there any way to read the data sent at a POST by chunks on ngx_lua,
instead of using req.get_body_data or req.get_post_args to get it in a
single shot?
The idea behind it is to have the availability to analyse the data being
sent before having the full transfer completed at the client side,
allowing, for example, to abort the transfer or crazy scenarios like those.
By taking a quick look at ngx_http_lua_req_body.c at
ngx_http_lua_ngx_req_read_body call, it seems that nginx is indeed
offering the capability to read the buffer by chunks:
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
"lua start to read buffered request body");
rc = ngx_http_read_client_request_body(r,
ngx_http_lua_req_body_post_read);
I know that it might appear that this scenario is a little bit
complicated, which it is :-), but it seems that the idea behind
performing some how buffered actions does work as suggested at the
ngx.req.init_body (with different effects of course):
ngx.req.init_body(128 * 1024) -- buffer is 128KB
for chunk in next_data_chunk() do
ngx.req.append_body(chunk) -- each chunk can be 4KB
end
ngx.req.finish_body()
Any Ideas? :-)
Thanks in advance and have a great weekend!
Cheers,
Dererk
--
BOFH excuse #399:
We are a 100% Microsoft Shop.