cURL is a standard HTTP client library that is distributed with many operating systems and can be used in PHP via the cURL extension. It offers functionality for many special cases which can occur for a HTTP client and make it a perfect choice for a HTTP adapter. It supports secure connections, proxy, all sorts of authentication mechanisms and shines in applications that move large files around between servers.
Example 478. Setting cURL options
<?php
$config = array(
'adapter' => 'Zend_Http_Client_Adapter_Curl',
'curloptions' => array(CURLOPT_FOLLOWLOCATION => true),
);
$client = new Zend_Http_Client($uri, $config);
By default the cURL adapter is configured to behave exactly like
the Socket Adapter and it also accepts the same configuration parameters
as the Socket and Proxy adapters. You can also change the cURL options by either
specifying the 'curloptions' key in the constructor of the adapter or by calling
setCurlOption($name, $value). The $name key
corresponds to the CURL_* constants of the cURL extension. You can
get access to the Curl handle by calling $adapter->getHandle();
Example 479. Transfering Files by Handle
You can use cURL to transfer very large files over HTTP by filehandle.
<?php
$putFileSize = filesize("filepath");
$putFileHandle = fopen("filepath", "r");
$adapter = new Zend_Http_Client_Adapter_Curl();
$client = new Zend_Http_Client();
$client->setAdapter($adapter);
$adapter->setConfig(array(
'curloptions' => array(
CURLOPT_INFILE => $putFileHandle,
CURLOPT_INFILESIZE => $putFileSize
)
));
$client->request("PUT");




