openresty / lua-resty-upload

Streaming reader and parser for http file uploading based on ngx_lua cosocket
404 stars 113 forks source link

Subrequest question #40

Closed SWSAmor closed 6 years ago

SWSAmor commented 6 years ago

Thank you for your work, i use this module without any problems for a year. But now I tried to handle the upload with the same script, but from a subrequest, and i got this:

attempt to read the request body in a subrequest stack traceback: coroutine 0: > [C]: in function 'req_socket' > /usr/lib/lua/luarocks/share/lua/5.1/resty/upload.lua:61: in function 'new'

i called the script with this:

local res = ngx.location.capture("/upl_worker", {share_all_vars = true, always_forward_body=true})

Is it impossible, or i miss something?

agentzh commented 6 years ago

@SWSAmor The error message is self-explanatory, you cannot read a client request body inside a subrequest, this is a limitation in nginx core's subrequest design. You should only read the request body from a main request.