Let's say I upload a file with PHP, CURL:
$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 );
Now suppose I need to manually set the content length header.
$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);
How to measure body size? (just specifying the file size as the length of the content does not work)
In another example, if the body contains data that is not the actual file. (manually set by postfields) In this situation, how would I get the length of the body content?
Thanks for any light on this, this seems to be a difficult problem.
stormist
source share