Reg. POST data body

ESWAR RAO eswar7028 at gmail.com
Wed May 1 09:34:17 UTC 2013


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20130501/ac303360/attachment.html>


More information about the nginx mailing list