ZF-7962: http proxy not fully supported

Description

Hello,

I experimented the Gdata library behind a firewall. I tried to upload photos to picasaweb and I think there is a bug because I'm able to login to google with this code:


    Zend_Loader::loadClass('Zend_Http_Client_Adapter_Proxy');
    $adapter = new Zend_Http_Client_Adapter_Proxy();
    $adapter->setConfig(array('proxy_host' => 'localhost', 'proxy_port' => 8888));
    $httpclient = new Zend_Gdata_HttpClient();
    $httpclient->setAdapter($adapter);
    $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, Zend_Gdata_Photos::AUTH_SERVICE_NAME, $httpclient);

But when the photo is uploaded, I got a timeout exception (see exception 1 bellow).

I looked at the code (Zend_Gdata_App::performHttpRequest) and I think the http proxy is not used when data type is "MediaMimeStream":


        if ($body instanceof Zend_Gdata_MediaMimeStream) {
            $usingMimeStream = true;
            $this->_httpClient->setRawDataStream($body, $contentType);
            $oldHttpAdapter = $this->_httpClient->getAdapter();

            if ($oldHttpAdapter instanceof Zend_Http_Client_Adapter_Proxy) {
                require_once 'Zend/Gdata/HttpAdapterStreamingProxy.php';
                $newAdapter = new Zend_Gdata_HttpAdapterStreamingProxy();
            } else {
                require_once 'Zend/Gdata/HttpAdapterStreamingSocket.php';
                $newAdapter = new Zend_Gdata_HttpAdapterStreamingSocket();
            }
            $this->_httpClient->setAdapter($newAdapter);
        }

I think the line $newAdapter = new Zend_Gdata_HttpAdapterStreamingProxy(); is wrong because the previous proxy adapter configuration is lost.

However, I tried to hardcode a setConfig(...) just after the $newAdapter is created but it doesn't work better (see exception 2 bellow).

Found exceptions are these:

1) Fatal error: Uncaught exception 'Zend_Gdata_App_HttpException' with message 'Unable to Connect to tcp://picasaweb.google.com:80. Error #110: Connection timed out' in /home/kerphi/Images/picuploader/ZendGdata-1.9.3PL1/library/Zend/Gdata/App.php:679 Stack trace:


#0 /home/kerphi/Images/picuploader/ZendGdata-1.9.3PL1/library/Zend/Gdata.php(219): Zend_Gdata_App->performHttpRequest('POST', 'http://picasawe...', Array, Object(Zend_Gdata_MediaMimeStream), 'multipart/relat...', NULL)

2) Fatal error: Uncaught exception 'Zend_Gdata_App_HttpException' with message 'Trying to write but we are connected to the wrong proxy server' in /home/kerphi/Images/picuploader/ZendGdata-1.9.3PL1/library/Zend/Gdata/App.php:681 Stack trace:


#0 /home/kerphi/Images/picuploader/ZendGdata-1.9.3PL1/library/Zend/Gdata.php(219): Zend_Gdata_App->performHttpRequest('POST', 'http://picasawe...', Array, Object(Zend_Gdata_MediaMimeStream), 'multipart/relat...', NULL)
#1 /home/kerphi/Images/picuploader/ZendGdata-1.9.3PL1/library/Zend/Gdata/App.php(888): Zend_Gdata->performHttpRequest('POST', 'http://picasawe...', Array, Object(Zend_Gdata_MediaMimeStream), 'multipart/relat...')

Comments

Bulk change of all issues last updated before 1st January 2010 as "Won't Fix".

Feel free to re-open and provide a patch if you want to fix this issue.