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

sayeo87 nginx-forum at
Tue Jun 30 02:33:27 MSD 2009

I am trying to develop a handler module in Nginx 0.7.59 to intercept POST requests and perform internal redirections based on the values in the POST data. The problem is, on larger POST requests (~ > 2KB), ngx_http_read_client_request_body() sometimes returns NGX_AGAIN instead of NGX_OK. I have read at various places that if one receives any other status than NGX_OK that that the module should immediately return that status. I have also read that after getting and returning NGX_AGAIN, NGINX will call your module again after other pending network activity. However, I have tried doing this but my module never gets called again.

What I have resorted to is to perform another ngx_http_read_client_request_body() call if I get an NGX_AGAIN. At least within the module this seems to work, but whenever I have to do this the resulting request to the upstream server always times out. But when I don't get NGX_AGAIN, everything is perfectly fine.

How should I handle these cases where ngx_http_read_client_request_body() returns NGX_AGAIN?

Thanks in advance!

Posted at Nginx Forum:,3545,3545#msg-3545

More information about the nginx mailing list