ZF-8896: setAuth() doesn't work when using the Curl adapter and digest auth

Description

The Zend_Http_Client::setAuth() method does not work properly when using the Zend_Http_Client_Adapter_Curl adapter against a server that requires digest authentication. For example, this fails:


$adapter = new Zend_Http_Client_Adapter_Curl();
$adapter->setCurlOption(CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
$client = new Zend_Http_Client();
$client->setAdapter($adapter);
$client->setUri($uri);
$client->setAuth($user, $pass);
$result = $client->request();

To make it work, you need to avoid the setAuth() method and instead pass the user/pass via a Curl option, like this:


$adapter = new Zend_Http_Client_Adapter_Curl();
$adapter->setCurlOption(CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
$adapter->setCurlOption(CURLOPT_USERPWD, $user . ':' . $pass);
$client = new Zend_Http_Client();
$client->setAdapter($adapter);
$client->setUri($uri);
$result = $client->request();

Since the setAuth() method is defined in Zend_Http_Client and not in Zend_Http_Client_Adapter_Abstract (and thus not overridable in Zend_Http_Client_Adapter_Curl,) I'm not sure about the best way to fix this.

Comments

No comments to display