Hi,
given PHP-4.0.5 (yes, I know..) and CURL lib 7.8.1 with SSL.
the command:
$cmd = "/usr/local/bin/curl -H 'Content-type: text/GlUpP' -d '".$data."' https://some.web.server/rolf/";
$s = exec($cmd);
Works perfectly. The intention is to post an xml document to another server. Where it is parsed by PHP.
To make this work, I have to set an unreconizable Content-type. Hence the type "text/GlUpP". This causes PHP to assign the content to the HTTP_RAW_POST_DATA. And I can then parse the XML data.
Well, back to my question. I dont like making calls to external programs through exec(). So I tried implementing it like this:
curl_setopt($ch, CURLOPT_URL,"https://some.web.server/rolf/");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER , 'Content-type: text/glupp');
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$resultat = curl_exec ($ch);
As you can se, I try to override the Content-type field in the header sent to the server. But the script receives the header with the standard x-www-application... encoded type.
Wich makes PHP try parsing the contents into variables, instead of assigning the content to HTTP_RAW_POST_DATA. Which is what I want..
So, the problem is solved, in a way. But why does not:
curl_setopt($ch, CURLOPT_HTTPHEADER , 'Content-type: text/glupp');
override the Content-type field. My interpretion of the documentation makes me belive that this should work (which it doesn't) ?