ZF-7990: URL endpoint setting is done AFTER authentification, it makes problems

Description

In Zend_Service_Amazon_S3 there is a small defect. You set endpoint after you do the authentication.

I attached the patch that fixes the problem.


--- .../library/Zend/Service/Amazon/S3.php  (revision 18447)
+++ .../library/Zend/Service/Amazon/S3.php  (working copy)
@@ -474,6 +474,7 @@
         $client = self::getHttpClient();
 
         $client->resetParameters();
+        $client->setUri($endpoint);
         $client->setAuth(false);
         // Work around buglet in HTTP client - it doesn't clean headers
         // Remove when ZHC is fixed
@@ -482,7 +483,6 @@
                                   'Range'       => null,
                                   'x-amz-acl'   => null));
 
-        $client->setUri($endpoint);
         $client->setHeaders($headers);

Comments

This patch fixes the problem

Fatal error: Call to a member function setUsername() on a non-object in /code/ilks/php/src/library/Zend/Http/Client.php on line 545

This is what I get

this is a workaround I have to use for now:

    $s3 = new Zend_Service_Amazon_S3($key, $secret);    
    Zend_Service_Amazon_S3::getHttpClient()->setUri('<a rel="nofollow" href="http://google.com">http://google.com</a>');
    return $s3;

in this scenario everything works fine

set endpoint before authentication.