Welcome! Log In Create A New Profile

Advanced

Re: [Nginx] perl module get an empty body

August 10, 2012 09:44AM
Hi Maxim,

Thanks for your reply.

I don't understand what you mean by "content handler" as I'm a noob in nginx perl usage (and I'm not sure it was clear enough for you). I tested http_content_length but it's empty also.
I really need to have the calling request body (I deleted the major part of my code but I parse some stuff in).

Let's say I want to return 3 to perl_set if the request body match "test" and 4 otherwise (and log it), I would do:

#!/usr/bin/perl

package switcher_test;
use nginx;
use Sys::Syslog;

my $facility = 'local2';

sub handler {
my $r = shift;

openlog('tester', 'ndelay', $facility);

$r->has_request_body(sub{});
if ($r->request_body =~ /.*test.*/) { return 3 };

syslog(LOG_DEBUG, 'request_body: '.$r->request_body);

return 4;
}

1;
__END__

It works but when another program (developed by another company who don't want to change the code) POST to my Nginx using:

pList.append('%s=%s' % (paramKey, urllib.quote_plus(unicode(paramValue))))

(cf. my test program above)

it doesn't works and Nginx timeouts.

According to your previous answer how would you do it ?

Thanks.

RĂ©mi
Subject Author Posted

[Nginx] perl module get an empty body

darkweaver871 August 10, 2012 06:03AM

Re: [Nginx] perl module get an empty body

darkweaver871 August 10, 2012 06:04AM

Re: [Nginx] perl module get an empty body

darkweaver871 August 10, 2012 07:03AM

Re: [Nginx] perl module get an empty body

darkweaver871 August 10, 2012 09:44AM

Re: [Nginx] perl module get an empty body

Maxim Dounin August 10, 2012 07:14AM

Re: [Nginx] perl module get an empty body

darkweaver871 August 10, 2012 09:46AM

Re: [Nginx] perl module get an empty body

darkweaver871 August 10, 2012 10:12AM

Re: [Nginx] perl module get an empty body

Maxim Dounin August 10, 2012 09:56AM

Re: [Nginx] perl module get an empty body

Maxim Dounin August 10, 2012 01:12PM

Re: [Nginx] perl module get an empty body

darkweaver871 August 12, 2012 06:32AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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