title: Getting content body from http post using php CURL
body: <p>I am trying to debug an http post the I am trying to send from list application.  I have been able to send the correct post from php CURL which corectly interfaces with my drupal 7 website and uploads an image.  </p>
  
  <p>In order to get this to work in my lisp application I really need to see the content body of my http post I have been able to see the headers using a call like this:</p>
  
  <pre><code>curl_setopt($curl,   CURLOPT_STDERR, $fp);
  curl_setopt($curl, CURLOPT_VERBOSE, 1);
  </code></pre>
  
  <p>and the headers look the same in my lisp application but I have been unable to examine the body of the post.  I have searched online and other people have asked this question but no one posted a response.  </p>
  
  <p>The content type of my http post is:</p>
  
  <pre><code>application/x-www-form-urlencoded
  </code></pre>
  
  <p>I have also tried many http proxy debuging tools but they only ever the http GET to get my php page but never capture the get sent from server once the php code is executed.  </p>
  
  <p>EDIT: I have added a code snipet showing where I actually upload the image file.  </p>
  
  <pre><code>// file
  $file = array(
    'filesize' =&gt; filesize($filename),
    'filename' =&gt; basename($filename),
    'file' =&gt; base64_encode(file_get_contents($filename)),
    'uid' =&gt; $logged_user-&gt;user-&gt;uid,
  );
  
  $file = http_build_query($file);
  
  // REST Server URL for file upload
  $request_url = $services_url . '/file';
  
  // cURL
  $curl = curl_init($request_url);
  curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-type: application/x-www-form-urlencoded'));
  curl_setopt($curl,   CURLOPT_STDERR, $fp);
  curl_setopt($curl, CURLOPT_VERBOSE, 1);
  curl_setopt($curl, CURLOPT_POST, 1); // Do a regular HTTP POST
  curl_setopt($curl, CURLOPT_POSTFIELDS, $file); // Set POST data
  curl_setopt($curl, CURLOPT_HEADER, FALSE);  // Ask to not return Header
  curl_setopt($curl, CURLOPT_COOKIE, "$cookie_session"); // use the previously saved session
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
  curl_setopt($curl, CURLOPT_FAILONERROR, TRUE);
  curl_setopt_array($curl, array(CURLINFO_HEADER_OUT =&gt; true) );
  $response = curl_exec($curl);
  </code></pre>