Varien_Http_Adapter_Curl Class Reference

List of all members.

Public Member Functions

 setConfig ($config=array())
 connect ($host, $port=80, $secure=false)
 write ($method, $url, $http_ver= '1.1', $headers=array(), $body= '')
 read ()
 close ()
 getErrno ()
 getError ()
 getInfo ($opt=0)

Protected Member Functions

 _getResource ()

Protected Attributes

 $_config = array()
 $_resource


Detailed Description

Definition at line 34 of file Curl.php.


Member Function Documentation

_getResource (  )  [protected]

Definition at line 147 of file Curl.php.

00148     {
00149         if (is_null($this->_resource)) {
00150             $this->_resource = curl_init();
00151         }
00152         return $this->_resource;
00153     }

close (  ) 

Close the connection to the server

Definition at line 140 of file Curl.php.

00141     {
00142         curl_close($this->_getResource());
00143         $this->_resource = null;
00144         return $this;
00145     }

connect ( host,
port = 80,
secure = false 
)

Connect to the remote server

Parameters:
string $host
int $port
boolean $secure

Definition at line 63 of file Curl.php.

00064     {
00065         //curl_setopt();
00066         if (isset($this->_config['timeout'])) {
00067             curl_setopt($this->_getResource(), CURLOPT_TIMEOUT, $this->_config['timeout']);
00068         }
00069         if (isset($this->_config['maxredirects'])) {
00070             curl_setopt($this->_getResource(), CURLOPT_MAXREDIRS, $this->_config['maxredirects']);
00071         }
00072         if (isset($this->_config['proxy'])) {
00073             curl_setopt ($this->_getResource(), CURLOPT_PROXY, $this->_config['proxy']);
00074         }
00075 
00076         return $this;
00077     }

getErrno (  ) 

Definition at line 155 of file Curl.php.

00156     {
00157         return curl_errno($this->_getResource());
00158     }

getError (  ) 

Definition at line 160 of file Curl.php.

00161     {
00162         return curl_error($this->_getResource());
00163     }

getInfo ( opt = 0  ) 

Get information regarding a specific transfer

Parameters:
int $opt CURLINFO option
Returns:
mixed

Definition at line 171 of file Curl.php.

00172     {
00173         return curl_getinfo($this->_getResource(), $opt);
00174     }

read (  ) 

Read response from server

Returns:
string

Definition at line 122 of file Curl.php.

00123     {
00124         $response = curl_exec($this->_getResource());
00125 
00126         // Remove 100 and 101 responses headers
00127         if (Zend_Http_Response::extractCode($response) == 100 ||
00128             Zend_Http_Response::extractCode($response) == 101) {
00129             $response = preg_split('/^\r?$/m', $response, 2);
00130             $response = trim($response[1]);
00131         }
00132 
00133         return $response;
00134     }

setConfig ( config = array()  ) 

Set the configuration array for the adapter

Parameters:
array $config

Definition at line 50 of file Curl.php.

00051     {
00052         $this->_config = $config;
00053         return $this;
00054     }

write ( method,
url,
http_ver = '1.1',
headers = array(),
body = '' 
)

Send request to the remote server

Parameters:
string $method
Zend_Uri_Http $url
string $http_ver
array $headers
string $body
Returns:
string Request as text

Definition at line 89 of file Curl.php.

00090     {
00091         if ($url instanceof Zend_Uri_Http) {
00092             $url = $url->getUri();
00093         }
00094         // set url to post to
00095         curl_setopt($this->_getResource(), CURLOPT_URL, $url);
00096         curl_setopt($this->_getResource(), CURLOPT_RETURNTRANSFER, true);
00097         if ($method == Zend_Http_Client::POST) {
00098             curl_setopt($this->_getResource(), CURLOPT_POST, true);
00099             curl_setopt($this->_getResource(), CURLOPT_POSTFIELDS, $body);
00100         }
00101         elseif ($method == Zend_Http_Client::GET) {
00102             curl_setopt($this->_getResource(), CURLOPT_HTTPGET, true);
00103         }
00104 
00105         if( is_array($headers) ) {
00106             curl_setopt($this->_getResource(), CURLOPT_HTTPHEADER, $headers);
00107         }
00108 
00109         curl_setopt($this->_getResource(), CURLOPT_HEADER, true);
00110         curl_setopt($this->_getResource(), CURLOPT_SSL_VERIFYPEER, 0);
00111         curl_setopt($this->_getResource(), CURLOPT_SSL_VERIFYHOST, 0);
00112 
00113 
00114         return $body;
00115     }


Member Data Documentation

$_config = array() [protected]

Definition at line 41 of file Curl.php.

$_resource [protected]

Definition at line 43 of file Curl.php.


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:25:03 2009 for Magento by  doxygen 1.5.8