ZF-1920: ClientLogin class creates a new Zend_Http_Client object, destroying proxy adapter settings

Description

After authenticating, the ClientLogin class creates a new Zend_Http_Client object--- ignoring previously set proxy adapter settings. This makes the authentication request succeed in going through the proxy, but all other requests with the client returned from the ClientLogin code will fail, as they won't be going through the proxy.

See: Zend_Gdata_ClientLogin::getHttpClient (line 132 -- $client = new Zend_Http_Client).

Comments

This also affects 1.5.x versions!!!

in ZF 1.5.2 line 143 following:


if ($response->getStatus() == 200) {
            $headers['authorization'] = 'GoogleLogin auth=' . $goog_resp['Auth'];
            $client = new Zend_Http_Client();
            $useragent = $source . ' Zend_Framework_Gdata/' . Zend_Version::VERSION;
            $client->setConfig(array(
                    'strictredirects' => true,
                    'useragent' => $useragent
                )
            );
            $client->setHeaders($headers);
            return $client;

Why don't you use the previous Zend_Http_Client and create a new one? You have already a Zend_Http_Client above!

In ZF 1.5.2 libe 75 following:


    public static function getHttpClient($email, $password, $service = 'xapi',
        $client = null,
        $source = self::DEFAULT_SOURCE,
        $loginToken = null,
        $loginCaptcha = null,
        $loginUri = self::CLIENTLOGIN_URI)
    {
        if (! ($email && $password)) {
            require_once 'Zend/Gdata/App/AuthException.php';
            throw new Zend_Gdata_App_AuthException('Please set your Google credentials before trying to authenticate');
        }

        if ($client == null) {
            $client = new Zend_Http_Client();
        }
        if (!$client instanceof Zend_Http_Client) {
            require_once 'Zend/Gdata/App/HttpException.php';
            throw new Zend_Gdata_App_HttpException('Client is not an instance of Zend_Http_Client.');
        }

Solution: remove the code which creates a new Zend_Http_Client or get the previous settings from the first Zend_Http_Client instance!

Fixed in r14204 and merged to 1-7 branch in r14205.