Hello agentz!
I had a look on the work-around with lua, but it seems too much work needs to be done to get it working with the lua-resty-upload module. Also, I like the solution with a lua-nginx-module modification better ...
Therefore I tried to implement it directly in nginx.
I looked at the function
static int ngx_http_lua_req_socket(lua_State *L) in
ngx_http_lua_socket_tcp.c, because the error with chunked request bodies gets thrown there.
I know I can check if the request is a chunked request by checking
r->headers_in.chunked.
I tried to use the function
ngx_http_parse_chunked(ngx_http_request_t *r, ngx_buf_t *b, ngx_http_chunked_t *ctx); when it's a chunked request in the bottom of the /* request body reader */ part, but I never managed to get any data to lua.
The function seemed to be the key for me, because it's also used in some changes where nginx added support for chunked request bodies:
https://github.com/nginx/nginx/commit/a79aeb7ca33d55f3bed89062b1bdfe24ee9a46cb
But to be honest, I have not much of an idea on which place modifications are to be done, so that lua gets the un-chunked-encoded data ...
Would it be possible to tell roughly in which parts changes need to be done?
Thank you!
Best Regards,
Michael
Am Sonntag, 5. April 2015 19:56:15 UTC+2 schrieb agentzh:
Hello!
On Sat, Apr 4, 2015 at 4:27 AM, Michael wrote:
> Is there any other possibility you can think of to send data to
> lua-resty-upload without knowing the acutal size in advance?
>
There does exist a work-around for reading the chunked request body
data in a streaming fashion, via using the "raw" request socket (i.e.,
ngx.req.socket(true)), as demonstrated by the following (declarative)
test case in ngx_lua' existing test suite:
https://github.com/openresty/lua-nginx-module/blob/75cc29ea64a87bc5cd447525893fda76b8d664b4/t/116-raw-req-socket.t#L784
But it would require some more work to make it work with
lua-resty-upload. Good luck with this (dirty) route :)
The most beautiful way to achieve this, however, as I've said in my
previous email, is to make the non-raw request socket API support
chunked encoding transparently, such that existing Lua libraries like
lua-resty-upload will just work with chunked request bodies out of the
box.
Regards,
-agentzh