Zend_Http_Client::setAdapter PHP Method

setAdapter() public method

While this method is not called more than one for a client, it is seperated from ->request() to preserve logic and readability
public setAdapter ( Zend_Http_Client_Adapter_Interface | string $adapter ) : null
$adapter Zend_Http_Client_Adapter_Interface | string
return null
    public function setAdapter($adapter)
    {
        if (is_string($adapter)) {
            try {
                Zend_Loader::loadClass($adapter);
            } catch (Zend_Exception $e) {
                /** @see Zend_Http_Client_Exception */
                require_once 'Zend/Http/Client/Exception.php';
                throw new Zend_Http_Client_Exception("Unable to load adapter '{$adapter}': {$e->getMessage()}", 0, $e);
            }
            $adapter = new $adapter();
        }
        if (!$adapter instanceof Zend_Http_Client_Adapter_Interface) {
            /** @see Zend_Http_Client_Exception */
            require_once 'Zend/Http/Client/Exception.php';
            throw new Zend_Http_Client_Exception('Passed adapter is not a HTTP connection adapter');
        }
        $this->adapter = $adapter;
        $config = $this->config;
        unset($config['adapter']);
        $this->adapter->setConfig($config);
    }

Usage Example

 /**
  * @return $this
  * @throws Zend_Http_Client_Exception
  */
 public function init()
 {
     $this->initConfig();
     $this->_http = new Zend_Http_Client();
     $this->_http->setAdapter(new Zend_Http_Client_Adapter_Curl());
     $this->_http->setHeaders(array('Accept' => 'application/' . static::API_RESPONSE_FORMAT, 'Authorization' => 'WSSE profile="UsernameToken"', 'X-WSSE' => $this->_getWsseHeader()));
     return $this;
 }
All Usage Examples Of Zend_Http_Client::setAdapter