Problem with post_action when used with return 202; and POST request

Maxim Dounin mdounin at mdounin.ru
Fri Aug 12 07:46:13 UTC 2011


Hello!

On Thu, Aug 11, 2011 at 02:38:44PM +0300, Pyry Hakulinen wrote:

> > Thank you for your report.  Please try the attached patch.
> 
> Thank you, the patch appears to be working fine, but because it
> discards the request body, it isn't going to work for our use case.
> 
> Our use case is, to POST data to nginx and let nginx asynchronously
> proxy it to somewhere else for processing, while freeing the client
> that did the POSTing to do other things.
> 
> I think the request body should be transferred to post_action
> location, and the location can then decide if it needs it or not.
> Attached is a patch against 1.0.5 that reads the body if post_action
> is used, but I'm not really sure if it's correct. My nginx-fu is still
> a bit lacking.

No, this is incorrect.  Body should be either read or discarded 
before response could be returned (else communication with clients 
which write body and only then read response will just deadlock).  
And it's up to code returning response to decide whether it needs 
body or not, post_action has nothing to do with it.  (I personally 
consider post_action to be a dirty hack which should be removed 
entirely, and it's not officially documented on purpose, but 
that's another story.)

In you particular case I would recommend actually using module to 
read body and return 202 response instead of using "return 202".

Maxim Dounin



More information about the nginx mailing list