12 messages in ru.sysoev.nginxRe: NGX_AGAIN and POST data
FromSent OnAttachments
Brian BrunsOct 5, 2008 6:58 pm 
Valery KholodkovOct 6, 2008 4:29 am 
Brian BrunsOct 6, 2008 5:35 am 
Valery KholodkovOct 6, 2008 6:53 am 
Brian BrunsOct 6, 2008 8:05 am 
Valery KholodkovOct 6, 2008 8:58 am 
Brian BrunsOct 7, 2008 10:16 am 
Valery KholodkovOct 8, 2008 1:09 am 
Brian BrunsOct 9, 2008 7:14 am 
Valery KholodkovOct 9, 2008 8:18 am 
Brian BrunsOct 14, 2008 8:08 pm 
Brian BrunsOct 14, 2008 8:42 pm 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: NGX_AGAIN and POST dataActions...
From:Brian Bruns (bria@gmail.com)
Date:Oct 14, 2008 8:42:11 pm
List:ru.sysoev.nginx

I believe I have solved my problem. At the end of my request body post_handler, I am now doing this:

ngx_http_send_header(r); rc = ngx_http_output_filter(r, &out); ngx_http_finalize_request(r, rc); return;

I still not sure this is quite right, particularly on which value I should be sending for the second argument to ngx_http_finalize_request(), but it does seem to work reliably.

Thank you for all your help,

Brian

Hi Valery,

First, thanks for all your help, I'm slowing getting a handle on the internal workings of nginx but it's been a bit of a learning curve.

I did some more digging and what I'm finding is that everything is indeed working correctly except the connection is not closed after the results are returned. Here is the transaction with my module in the loop:

request:

POST /hello HTTP/1.0 Content-Length: 10

abcd=12345

response:

HTTP/1.1 200 OK Server: nginx/0.7.19 Date: Wed, 15 Oct 2008 03:02:41 GMT Content-Type: text/plain Content-Length: 11 Last-Modified: Mon, 28 Sep 1970 06:00:00 GMT Connection: close

hello world

The connection then hangs until another character is sent from the client to the server at which time it closes.

I've replicated the same request using fastcgi/perl and it works flawlessly.

Any thoughts on why my module would require additional input from the client to close the connection?

Thanks again,

2008/10/9 Valery Kholodkov <valery+ngin@grid.net.ru>:

What I want to do is "return ngx_http_output_filter(r, &out);" just like before, but that seems to not work, my question is should it work from the request_body_handler and is there any special trick to doing so or better yet an existing module I can look at for pointers? I couldn't find one, virtually everything that uses ngx_http_read_client_request_body is an upstream module.

I don't know whether a module doing similar thing exists, but I assume you invoke ngx_http_send_header, interpret the result, call ngx_http_output_filter and it should be ok.