Zend_Http_Client_Adapter_Exception example

/** * Set the configuration array for the adapter * * @param Zend_Config | array $config */
    public function setConfig($config = array())
    {
        if ($config instanceof Zend_Config) {
            $config = $config->toArray();

        } elseif (is_array($config)) {
            throw new Zend_Http_Client_Adapter_Exception(
                'Array or Zend_Config object expected, got ' . gettype($config)
            );
        }

        foreach ($config as $k => $v) {
            $this->config[strtolower($k)] = $v;
        }
    }


    /** * Connect to the remote server * * @param string $host * @param int $port * @param boolean $secure * @param int $timeout * @throws Zend_Http_Client_Adapter_Exception */
/** * Set the configuration array for the adapter * * @param Zend_Config | array $config */
    public function setConfig($config = array())
    {
        if ($config instanceof Zend_Config) {
            $config = $config->toArray();

        } elseif (is_array($config)) {
            throw new Zend_Http_Client_Adapter_Exception(
                'Array or Zend_Config object expected, got ' . gettype($config)
            );
        }

        foreach ($config as $k => $v) {
            $this->config[strtolower($k)] = $v;
        }
    }

    /** * Retrieve the array of all configuration options * * @return array */
/** * Adapter constructor * * Config is set using setConfig() * * @return void * @throws Zend_Http_Client_Adapter_Exception */
    public function __construct()
    {
        if (!extension_loaded('curl')) {
            throw new Zend_Http_Client_Adapter_Exception('cURL extension has to be loaded to use this Zend_Http_Client adapter.');
        }
        $this->_invalidOverwritableCurlOptions = array(
            CURLOPT_HTTPGET,
            CURLOPT_POST,
            CURLOPT_PUT,
            CURLOPT_CUSTOMREQUEST,
            CURLOPT_HEADER,
            CURLOPT_RETURNTRANSFER,
            CURLOPT_HTTPHEADER,
            CURLOPT_POSTFIELDS,
            CURLOPT_INFILE,
            
public function write(
        $method$uri$http_ver = '1.1', $headers = array()$body = ''
    )
    {
        // If no proxy is set, fall back to default Socket adapter         if (!$this->config['proxy_host']) {
            return parent::write($method$uri$http_ver$headers$body);
        }

        // Make sure we're properly connected         if (!$this->socket) {
            throw new Zend_Http_Client_Adapter_Exception(
                'Trying to write but we are not connected'
            );
        }

        $host = $this->config['proxy_host'];
        $port = $this->config['proxy_port'];

        if ($this->connected_to[0] != "tcp://$host"
            || $this->connected_to[1] != $port
        ) {
            throw new Zend_Http_Client_Adapter_Exception(
                
Home | Imprint | This part of the site doesn't use cookies.