Welcome! Log In Create A New Profile

Advanced

Reg. POST data body

ESWAR RAO
May 01, 2013 05:36AM
Hi All,

I am trying to collect the POST request body using $request_body but I am
unable to collect it in config file:

# curl -X POST -d "param1=value1&param2=value2" '
http://localhost:8031/test1/test2/' --header "Content-Type:application/json"

location /test1 {
............................
if ( $request_body ~ (.*?)(=)(.*?)(&)(.*?)(=)(.*) )
{
echo $1; echo $2; echo $3;
}
}

But when I tried to use the nginx-echo module, I was able to print it but I
couldn't use it in if().

location /test1 {
............................
echo_read_request_body;
echo $request_body;
set $foo $echo_request_body;
echo $foo;
if ( $foo ~ (.*?)(=)(.*?)(&)(.*?)(=)(.*) )
{
echo $1; echo $2; echo $3;
}
}

#curl -X POST -d "param1=value1&param2=value2" '
http://localhost:8031/test1/test2/' --header "Content-Type:application/json"
param1=value1&param2=value2

foo value is not getting echoed out. So the condition is not entering if().

Actually I intention is to load balance according to data in POST request.

Thanks
Eswar
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Reg. POST data body

ESWAR RAO May 01, 2013 05:36AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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