Reading large request body using ngx_http_read_client_request_body

NginxNewbee nginx-forum at
Mon May 20 19:04:05 UTC 2019

Thanks for your comments, Maxim. I truly appreciate it.

For first comment, the reason I chose to do request processing on thread is
so it wouldn't block nginx. We launch one thread per request (from content
handler). There will never will be multiple threads working on a request. r
is passed onto a thread callback. Inside that callback, we extract headers,
request body etc. from r and store it in our own objects. Then we do some
compute (business logic) and then generate a response and write to output
buffers of r. Then thread returns and its completion handler is called by
nginx. In the completion handler we finalize request (with NGX_DONE). 
Assumption here is that nginx wouldn't be messing with object r as long as
our thread is executing (since we haven't finalized request yet). With this
context, If you still think this isn't correct (and because of thread, I am
seeing issue in reading body for large content size), I'll be go ahead and
change my code and not use nginx  functions on thread.

For second comment - I may have not it explained correctly in my first post,
but we do not call finalize request until thread finishes.

Posted at Nginx Forum:,284214,284222#msg-284222

More information about the nginx mailing list