title: PHP CURL: Manually setting the content-length header
body: <p>Say I upload a file with PHP, CURL:</p>
  
  <pre><code>$postData = array();
  
  $postData['file_name'] = "test.txt";
  $postData['submit'] = "UPLOAD";
  
  $ch = curl_init();
  
  curl_setopt($ch, CURLOPT_URL, $url );
  curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
  curl_setopt($ch, CURLOPT_POST, 1 );
  curl_setopt($ch, CURLOPT_POSTFIELDS, $postData );
  </code></pre>
  
  <p>Now assume I have to manually set the content-length header.</p>
  
  <pre><code>$headers=array(
       "POST /rest/objects HTTP/1.1",
       'accept: */*',
       "content-length: 0" //instead of 0, how could I get the length of the body from curl?
      )
  curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); //set headers
  $response = curl_exec($ch);
  </code></pre>
  
  <p>How would I measure the size of the body? (just specifying the filesize as content length doesn't seem to work)</p>
  
  <p>In another example what if the body contains data that is not an actual file. (manually set by postfields) In that situation how would I get the content length of the body?</p>
  
  <p>Thanks for any light shed on this, it appears to be a tough issue.</p>