Welcome! Log In Create A New Profile

Advanced

Re: ngx_http_read_client_request_body() and ACCESS_PHASE handler

Srebrenko Šehić
April 23, 2010 07:22AM
On Fri, Apr 23, 2010 at 10:54 AM, agentzh <agentzh@gmail.com> wrote:

Hi,

> When your rewrite/access handler returns NGX_AGAIN or NGX_DONE, your
> handler will get called again and again (mostly triggered by writable
> event and other hooks). (See ngx_http_core_module.c:1059.)
>
> When you handler returns NGX_OK, it means skipping all the handlers in
> the current rewrite/access phase, and giving the control to the first
> handler in the next phase. Normally we just return NGX_DONE here to
> let nginx's phase engine run the next handler in the current phase (if
> any).
>
> I think you should call ngx_http_read_client_request_body in your
> handler *only once*. If it gets called a second time, it will simply
> returns NGX_OK. (See ngx_http_request_body.c:43.)

Now, when a POST request (the one the fails) my access handler is only
called once. The access handler also only calls
ngx_http_read_client_request_body () once. What happens is that when
my callback handler (ngx_http_dummy_payload_handler) is called, the
request processing simply stops there. nginx error log shows this:

2010/04/23 13:14:04 [debug] 876#0: *3 access phase: 6
2010/04/23 13:14:04 [debug] 876#0: *3 access phase: 7
2010/04/23 13:14:04 [debug] 876#0: *3 ngx_http_dummy_access_handler: enter
2010/04/23 13:14:04 [debug] 876#0: *3 http client request body preread 436
2010/04/23 13:14:04 [debug] 876#0: *3 http read client request body
2010/04/23 13:14:04 [debug] 876#0: *3 http client request body recv 1896
2010/04/23 13:14:04 [debug] 876#0: *3 http client request body rest 10520
2010/04/23 13:14:04 [debug] 876#0: *3 ngx_http_dummy_access_handler: rc=-2
2010/04/23 13:14:04 [debug] 876#0: *3 ngx_http_dummy_access_handler:
rc=NGX_AGAIN, return
2010/04/23 13:14:04 [debug] 876#0: *3 http run request: "/test/upload.php?"
2010/04/23 13:14:04 [debug] 876#0: *3 http read client request body
2010/04/23 13:14:04 [debug] 876#0: *3 http client request body recv 4380
2010/04/23 13:14:04 [debug] 876#0: *3 http client request body rest 6140
2010/04/23 13:14:04 [debug] 876#0: *3 http run request: "/test/upload.php?"
2010/04/23 13:14:04 [debug] 876#0: *3 http read client request body
2010/04/23 13:14:04 [debug] 876#0: *3 http client request body recv 1916
2010/04/23 13:14:04 [warn] 876#0: *3 a client request body is buffered
to a temporary file /var/nginx/tmp/client_body_temp/0000987649,
client: 192.168.0.85, server: 192.168.0.23, request: "POST
/test/upload.php HTTP/1.1", host: "192.168.0.23:8080", referrer:
"http://192.168.0.23:8080/test/upload.html"
2010/04/23 13:14:04 [debug] 876#0: *3 http client request body recv 4224
2010/04/23 13:14:04 [debug] 876#0: *3 http client request body rest 0
2010/04/23 13:14:04 [debug] 876#0: *3 ngx_http_dummy_payload_handler: enter
2010/04/23 13:14:04 [debug] 876#0: *3 ngx_http_dummy_payload_handler: ctx->rc=-2
2010/04/23 13:14:04 [debug] 876#0: *3 ngx_http_dummy_payload_handler:
read->ready != 1

No more output after the above. read->ready != 1 shows the value of
r->connection->read->ready which is 0 when the return value of
ngx_http_read_client_request_body () is NGX_AGAIN.

[ ... snip ...]

> We're currently working on a module named ngx_form_input that calls
> ngx_http_read_client_request_body in a rewrite phase handler ;) We're
> passing all of our existing tests at the moment :)

Do you mind sharing this module (or relevant bits)? It might give me
some inspiration or guide me in the right direction.

Thanks for all your help.

Best regards,
Srebrenko

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

ngx_http_read_client_request_body() and ACCESS_PHASE handler

Srebrenko Šehić 7171 April 22, 2010 10:20AM

Re: ngx_http_read_client_request_body() and ACCESS_PHASE handler

Yuriy Taraday 1737 April 22, 2010 12:18PM

Re: ngx_http_read_client_request_body() and ACCESS_PHASE handler

Srebrenko Šehić 1565 April 22, 2010 05:50PM

Re: ngx_http_read_client_request_body() and ACCESS_PHASE handler

agentzh 2035 April 23, 2010 04:56AM

Re: ngx_http_read_client_request_body() and ACCESS_PHASE handler

agentzh 1414 April 23, 2010 04:56AM

Re: ngx_http_read_client_request_body() and ACCESS_PHASE handler

Srebrenko Šehić 1699 April 23, 2010 07:22AM

Re: ngx_http_read_client_request_body() and ACCESS_PHASE handler

agentzh 2066 April 24, 2010 05:06AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 170
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