title: Curl not working and returning 400 Bad Request
body: <p>I'm trying to make a curl request to post some data to a restful api.
  That's the code I have:</p>
  
  <pre><code>$header = "POST HTTP/1.0 \r\n";
  $header .= "Content-type: text/xml \r\n";
  $header .= "Content-length: " . strlen($xml) . " \r\n";
  $header .= "Content-transfer-encoding: text \r\n";
  $header .= "Connection: close \r\n\r\n";
  $header .= $xml;
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_TIMEOUT, 4);
  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $header);
  curl_setopt($ch, CURLOPT_POST, true);
  
  $data = curl_exec($ch);
  if (curl_errno($ch)) {
      print curl_error($ch);
  } else {
      curl_close($ch);
      echo 'success';
  }
  </code></pre>
  
  <p><code>$xml</code> contains the data I want to post.</p>
  
  <p>Well, the problem is that when I run the script it echoes 'Success' but the post is not really done.</p>
  
  <p>What could be the problem here?</p>
  
  <p>Thanks.</p>
  
  <p>EDIT: <code>var_dump($data)</code> returns a <code>400 Bad Request</code> is there any way to solve this?</p>