[Nginx] perl module get an empty body

Maxim Dounin mdounin at mdounin.ru
Fri Aug 10 11:12:26 UTC 2012


On Fri, Aug 10, 2012 at 06:03:14AM -0400, darkweaver871 wrote:

> Hi all,
> I'm using Nginx as a reverse proxy and I use Nginx perl module to
> inspect my requests and redirect to a different upstream.
> It works well but some of request_body are empty and others just make
> nginx timeout.


>         perl_modules /opt/test/perl/;
>         perl_require switcher_test.pm;
>         perl_set $test switcher_test::handler;


> sub handler {
>         my $r = shift;
>         if($r->has_request_body(sub{})) { return 3 };

This doesn't work as $r->has_request_body() currently assumes it's 
called from a perl content handler, not from a perl variable 
handler, and does bad things if called from a variable handler.

You may try to test $http_content_length instead.

Maxim Dounin

More information about the nginx mailing list