For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

Erik_27939's avatar
Erik_27939
Icon for Nimbostratus rankNimbostratus
Apr 01, 2014

HTTP Post

I am trying to create an HTTP Post monitor and i have the following 2 snipits that work:

1:

$url = "http://[pool_mem_ip]:[pool_mem_port]/search";

$options = array(
  'http' => array(
     'method'  => 'POST',
     'content' => "{c: '', q: 'hammock', p: '1', l: 'dev', e: 'Production', rj: '1'}" ,
     'header'=>  "Content-Type: application/json\r\n" .
                "Accept: application/json\r\n"
   )
);

$context  = stream_context_create( $options );
$result = file_get_contents( $url, false, $context );
echo $result;

2:

curl -d "{c: '', q: 'hammock', p: '1', l: 'dev', e: 'Production', rj: '1'}" http://[pool_mem_ip]:[pool_mem_port]/search

However, when I go to setup the monitor, I just get a 500 internal server error. Below is the send string:

POST /search HTTP/1.0\r\nContent-Type: application/json\r\nAccept: application/json\r\n\r\n{c: '', q: 'hammock', p: '1', l: 'dev', e: 'Production', rj: '1'}

I am assuming that I am formatting the send string incorrectly. Any thoughts as to why this post isn't working when the php post works fine? Thanks in advance.

1 Reply

  • Two thoughts off the top of my head:

     

    1. It's very likely that your Ajax and cURL scripts are auto-injecting the Content-Length header. If you put a -v on your cURL statement, you should see all of the send and receive headers.

       

    2. I don't think this matters as much, but since you're not being explicit in the cURL statement, it's probably inserting an application/x-www-form-urlencoded mime type header. I guess I would check via your -v cURL test to make sure that mime type isn't required.