Welcome! Log In Create A New Profile

Advanced

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

Maxim Dounin
June 29, 2009 07:21PM
Hello!

On Mon, Jun 29, 2009 at 06:33:27PM -0400, sayeo87 wrote:

> 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.

General recomendation is: read code instead of "various places".
Expected module behaviour depend highly on exact place where it's used.

For this particular case try reading what other
ngx_http_read_client_request_body() callers do, e.g.
ngx_http_proxy_module. I believe it's clear enough. And the code
behind ngx_http_read_client_request_body() itself also deserves
some reading if you want to understand how it works.

> 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.

Calling ngx_http_read_client_request_body() again won't do
anything good. As you can see from first several lines of this
function - it will just call completion handler when called again.

Maxim Dounin

>
> How should I handle these cases where ngx_http_read_client_request_body() returns NGX_AGAIN?
>
> Thanks in advance!
>
> Posted at Nginx Forum: http://forum.nginx.org/read.php?2,3545,3545#msg-3545
>
>
Subject Author Posted

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

sayeo87 June 29, 2009 06:33PM

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

Maxim Dounin June 29, 2009 07:21PM

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

Mike Smith June 29, 2009 07:42PM

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

sayeo87 June 30, 2009 01:29PM

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

Valery Kholodkov July 01, 2009 11:52AM

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

CarlWang November 07, 2011 11:36AM

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

Maxim Dounin November 07, 2011 12:50PM

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

CarlWang November 07, 2011 11:31PM

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

agentzh November 08, 2011 01:58AM

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

CarlWang November 08, 2011 10:23AM

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

CarlWang November 08, 2011 11:44AM

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

agentzh November 08, 2011 08:30PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 294
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready