ngx_http_read_client_request_body not always being called?

Sergey Kandaurov pluknet at nginx.com
Tue Aug 16 14:41:57 UTC 2022


> On 16 Aug 2022, at 00:35, atrocitus <nginx-forum at forum.nginx.org> wrote:
> 
> (I wanted to post this to the Nginx Development group but it's read only)

You can subscribe to the nginx development mailing list:
https://mailman.nginx.org/mailman3/lists/nginx-devel.nginx.org/

> 
> I'm developing a module which will receive post data then print out "Done".
> "Done" will be printed out regardless if it's a "POST" or a "GET". Issue I'm
> having is ngx_http_read_client_request_body is not always calling my call
> back, I have to wait a few seconds / resubmit form before it works. Is there
> a caching issue I'm not aware of? I'm doing this from bash command line, a
> simple CURL command.
> 
> Here is what I have in my "cmd_handler":
> {
>    if (r->method == NGX_HTTP_POST)
>        ngx_http_read_client_request_body(r, ngx_http_form_read)
> 
>    ngx_str_set(&r->headers_out.content_type, "text/html")
>    ///....more out data definitions
>    ngx_http_output_filter(r, out);
>    ngx_http_finalize(request, r, NGX_DONE)
>    return NGX_DONE
> }
> 
> In my ngx_http_form_read, I have the following: 
> {
>    #if defined(ngx_version) && nginx_version >= 8011
>    r->main->count--;
>    #endif 
> 
> //form parsing data
>   // no return, this is a void?
> 
> }
> 

I see numerous issues in your code, including direct manipulation
with the request count and missing error handling.

See the complete example of handling request body:
http://nginx.org/en/docs/dev/development_guide.html#http_request_body

-- 
Sergey Kandaurov



More information about the nginx mailing list