NGX_AGAIN and POST data

Brian Bruns brian.bruns at gmail.com
Mon Oct 6 16:35:31 MSD 2008


Ok, now I'm really confused, here is my call to
ngx_http_read_client_request_body:

    rc = ngx_http_read_client_request_body(r,
ngx_http_mymodule_request_body_handler);

If I use any other client (firefox, links, wget)  then
ngx_http_mymodule_request_body_handler gets called.

Using urllib, which causes the NGX_AGAIN return, I get the following
in the log (the first statement is mine after the call to
ngx_http_read_client_request_body prior to returning NGX_AGAIN to the
caller).

2008/10/06 07:23:37 [alert] 34159#0: *5 failed to read client request
body, client: 192.168.16.1, server: localhost, request: "POST /sql
HTTP/1.0", host: "192.168.16.1:8081"
2008/10/06 07:23:37 [debug] 34159#0: *5 http finalize request: -2, "/sql?"
2008/10/06 07:23:37 [debug] 34159#0: *5 event timer add: 6: 60000:3525165053
2008/10/06 07:23:37 [debug] 34159#0: timer delta: 1
2008/10/06 07:23:37 [debug] 34159#0: posted events 00000000
2008/10/06 07:23:37 [debug] 34159#0: worker cycle
2008/10/06 07:23:37 [debug] 34159#0: kevent timer: 60000, changes: 0
2008/10/06 07:23:37 [debug] 34159#0: kevent events: 1
2008/10/06 07:23:37 [debug] 34159#0: kevent: 6: ft:-1 fl:0025
ff:00000000 d:84 ud:002280B5
2008/10/06 07:23:37 [debug] 34159#0: *5 http test reading
2008/10/06 07:23:37 [debug] 34159#0: timer delta: 1
2008/10/06 07:23:37 [debug] 34159#0: posted events 00000000
2008/10/06 07:23:37 [debug] 34159#0: worker cycle
2008/10/06 07:23:37 [debug] 34159#0: kevent timer: 59999, changes: 0


My request_body_handler never gets called and the client eventually times out.

Thanks again,

Brian

2008/10/6 Valery Kholodkov <valery+nginxen at grid.net.ru>:
>
>> The confusing part to me is the following lines from
>> src/http/ngx_http_core_module.c:
>>
>>     if (r->content_handler) {
>>         r->write_event_handler = ngx_http_request_empty_handler;
>>         ngx_http_finalize_request(r, r->content_handler(r));
>>         return NGX_OK;
>>     }
>>
>> which appears to (according the debug stuff in the log) simply close
>> out the connection regardless of the return value from
>> content_handler().  Shouldn't my module be getting re-called when more
>> data is available from the connection or am I misunderstanding
>> something?
>
> No. post_handler (the second argument of
> ngx_http_read_client_request_body) should be called when the body will be
> successfully received.
>
> ngx_http_finalize_request does not close the connection whenever rc ==
> NGX_AGAIN. Instead ngx_http_read_client_request_body sets read handler to
> ngx_http_read_client_request_body_handler. Therefore the read handler will
> be recalled, not your handler.
>
> --
> Best regards,
> Valery Kholodkov
>
>
>





More information about the nginx mailing list