I'm sending xml document through post. I get no error messages, but the document that is send through POST is empty. What can be a problem?

<?php
include 'QI.xml';
$url = "http://localhost/App.aspx";

    $post_string = $request;

   $header = array("POST $url HTTP/1.0\r\n",
   "Content-type: text/xml\r\n",
   "Content-Length: ".strlen($post_string)."\r\n",$post_string);

   $ch = curl_init();
   curl_setopt($ch, CURLOPT_URL,$url);
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
   curl_setopt($ch, CURLOPT_TIMEOUT, 10);
   curl_setopt($ch, CURLOPT_CUSTOMREQUEST,'POST');
   curl_setopt($ch, CURLOPT_HTTPHEADER, $header);

   $data = curl_exec($ch);
   if (curl_errno($ch)) {
       print curl_error($ch);
   } else {
       curl_close($ch);
     echo "No Errors";
  }
    print_r($data);
   $xml_parser = xml_parser_create();
   xml_parser_set_option($xml_parser,XML_OPTION_CASE_FOLDING,0);
   xml_parser_set_option($xml_parser,XML_OPTION_SKIP_WHITE,1);
   xml_parse_into_struct($xml_parser, $data, $vals, $index);
   xml_parser_free($xml_parser);

?>

    Remove "\r\n" from the ends of your header array lines (except the last one) and see what happens. Curl adds them automatically.

      Write a Reply...