You can create your own connection adapters and use them. You could, for example, create a connection adapter that uses persistent sockets, or a connection adapter with caching abilities, and use them as needed in your application.
In order to do so, you must create your own adapter class that implements
Zend_Http_Client_Adapter_Interface interface. The following
example shows the skeleton of a user-implemented adapter class. All the public
functions defined in this example must be defined in your adapter as well:
Example 497. Creating your own connection adapter
* Set the configuration array for the adapter
* @param array $config
public function setConfig($config = array())
// This rarely changes - you should usually copy the
// implementation in Zend_Http_Client_Adapter_Socket.
* Connect to the remote server
* @param string $host
* @param int $port
* @param boolean $secure
public function connect($host, $port = 80, $secure = false)
// Set up the connection to the remote server
* Send request to the remote server
* @param string $method
* @param Zend_Uri_Http $url
* @param string $http_ver
* @param array $headers
* @param string $body
* @return string Request as text
public function write($method,
$http_ver = '1.1',
$headers = array(),
$body = '')
// Send request to the remote server.
// This function is expected to return the full request
// (headers and body) as a string
* Read response from server
* @return string
public function read()
// Read response from remote server and return it as a string
* Close the connection to the server
public function close()
// Close the connection to the remote server - called last.
// Then, you could use this adapter:
$client = new Zend_Http_Client(array(
'adapter' => 'MyApp_Http_Client_Adapter_BananaProtocol'