php curl doesnt send large xml
<p>I have used curl to send XML to a web service as below,when my XML is short there is no problem, but when I want to send a large XML I get <code>Recv failure: Connection reset by peer</code> or <code>http://www.w3.org/2005/08/addressing/soap/faultsoapenv:Receivercom.ctc.wstx.exc.WstxEOFException: Unexpected EOF in prolog at [row,col {unknown-source}]: [1,0]</code> error.
I removed <code>Content-Length</code> from header but nothing changed. I also added <code>.htaccess</code> file with <code>php_value post_max_size 1024M</code> code. how can I solve this problem?</p>

<pre><code>$url     = "http:/xxxx?wsdl";
$header  = "POST http://xxxxx/ HTTP/1.1\r\n";
$header .= "Content-Type: text/xml;charset=UTF-8 \r\n";
$header .= "SOAPAction: '' \r\n";
$header .= "servicekey:".$servicekey."\r\n";
$header .= "Content-Length: 2171 \r\n"; 
$header .= "Host: x.x.x.x:xx \r\n";
$header .= "Connection: Keep-Alive\r\n";
$header .= "User-Agent: Apache-HttpClient/4.1.1 (java 1.5)\r\n\r\n";
$header .= $post_string;

$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, 100);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $header);
curl_setopt($ch, CURLOPT_VERBOSE, true);

$data = curl_exec($ch);

if(curl_errno($ch))
  {
    $error = array();
    array_push($error, curl_error($ch));
    return $error;
  }

 else
      {
        $result = array();
        array_push($result, $data);
        return $result;
      }
</code></pre>