How to handle NGX_AGAIN returned by ngx_http_read_client_request_body() within handler module?

Maxim Dounin mdounin at mdounin.ru
Mon Nov 7 17:47:59 UTC 2011


Hello!

On Mon, Nov 07, 2011 at 11:36:10AM -0500, CarlWang wrote:

> I have a similar problem here.
> My handler module in Nginx is supposed to intercept POST requests,
> analyse it and send response( the response body maybe larger than 64k).
> Of course, I used ngx_http_read_client_request_body to register my
> request_body_handler.
> The request_body_handler does some computing and calls
> ngx_http_output_filter(r,out) to send the response.
> Here is the problem. If this response is less than 64k, it works fine.
> But if this response is larger than 64k, the ngx_http_output_filter will
> return NGX_AGAIN. However, since it's in the request_body_handler
> function and it has nothing to return. I can't figure out how to handle
> this NGX_AGAIN.
> 
> Can anyone help me out? Thanks a lot.

You have to finalize request as usual, 

    ngx_http_finalize_request(r, ngx_http_output_filter(r, out));

will do all work as long as you have full response in the "out" 
chain.

Maxim Dounin



More information about the nginx mailing list