title: curl returns "Failure when receiving data from the peer"
body: <p>I'm retrieving data from an URL using curl.</p>
  
  <p>Everything works fine if the php code is called via a HTTP request or if the URL is entered in Firefox. If the very same code is executed from a PHP CLI script curl_exec returns false. The error message is "Failure when receiving data from the peer".</p>
  
  <p>Any ideas why curl is not working?</p>
  
  <p>When I set the curl output to verbose I get:</p>
  
  <pre><code>Setting curl to verbose gives:
  &lt; HTTP/1.1 200 OK
  &lt; Server: Apache-Coyote/1.1
  &lt; Last-Modified: Mon, 01 Aug 2011 13:04:59 GMT
  &lt; Cache-Control: no-store
  &lt; Cache-Control: no-cache
  &lt; Cache-Control: must-revalidate
  &lt; Cache-Control: pre-check=0
  &lt; Cache-Control: post-check=0
  &lt; Cache-Control: max-age=0
  &lt; Pragma: no-cache
  &lt; Expires: Thu, 01 Jan 1970 00:00:00 GMT
  &lt; Content-Type: text/xml
  &lt; Transfer-Encoding: chunked
  &lt; Date: Mon, 01 Aug 2011 13:04:58 GMT
  &lt; 
  *   Trying 153.46.254.70... * Closing connection #0
  * Failure when receiving data from the peer
  </code></pre>
  
  <p>This is the Code:</p>
  
  <pre><code>// if curl is not installed we trigger an alert, and exit the function
  if (!function_exists('curl_init')){
      watchdog('sixtk_api', 'curl is not installed, api call cannot be executed',array(),WATCHDOG_ALERT);
      return $this;
  }
  // OK cool - then let's create a new cURL resource handle
  $ch = curl_init();
  
  // Set URL to download
  curl_setopt($ch, CURLOPT_URL, $this-&gt;request);
  
  // Should cURL return or print out the data? (true = return, false = print)
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  
  // Timeout in seconds
  curl_setopt($ch, CURLOPT_TIMEOUT, 180);
  
  
  // Download the given URL, and return output
  $output = curl_exec($ch);
  if (!$output) {
      $error = curl_error($ch);
    echo($error);
  }
  
  // Close the cURL resource, and free system resources
  curl_close($ch);
  </code></pre>