Issues

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

Issue Type: Bug Created: 2010-01-21T13:15:19.000+0000 Last Updated: 2012-11-20T21:38:07.000+0000 Status: Open Fix version(s): Reporter: Alex Howansky (alex.howansky) Assignee: None Tags: - Zend_Http_Client

Related issues: Attachments:

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:

<pre class="highlight">
$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:

<pre class="highlight">
$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

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts