Browse Source

Backporting 17124 into trunk

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@17131 44c647ce-9c0f-0410-b52a-842ac1e357ba
shahar 16 years ago
parent
commit
0305440184

+ 7 - 7
library/Zend/Http/Client.php

@@ -1039,22 +1039,22 @@ class Zend_Http_Client
             return '';
         }
 
-        // If mbstring overloads substr and strlen functions, we have to 
+        // If mbstring overloads substr and strlen functions, we have to
         // override it's internal encoding
-        if (function_exists('mb_internal_encoding') && 
+        if (function_exists('mb_internal_encoding') &&
            ((int) ini_get('mbstring.func_overload')) & 2) {
 
             $mbIntEnc = mb_internal_encoding();
             mb_internal_encoding('ASCII');
         }
-        
+
         // If we have raw_post_data set, just use it as the body.
         if (isset($this->raw_post_data)) {
             $this->setHeaders(self::CONTENT_LENGTH, strlen($this->raw_post_data));
             if (isset($mbIntEnc)) {
                 mb_internal_encoding($mbIntEnc);
             }
-            
+
             return $this->raw_post_data;
         }
 
@@ -1098,7 +1098,7 @@ class Zend_Http_Client
                     if (isset($mbIntEnc)) {
                         mb_internal_encoding($mbIntEnc);
                     }
-                    
+
                     /** @see Zend_Http_Client_Exception */
                     require_once 'Zend/Http/Client/Exception.php';
                     throw new Zend_Http_Client_Exception("Cannot handle content type '{$this->enctype}' automatically." .
@@ -1111,11 +1111,11 @@ class Zend_Http_Client
         if ($body || $this->method == self::POST || $this->method == self::PUT) {
             $this->setHeaders(self::CONTENT_LENGTH, strlen($body));
         }
-        
+
         if (isset($mbIntEnc)) {
             mb_internal_encoding($mbIntEnc);
         }
-        
+
         return $body;
     }
 

+ 7 - 7
library/Zend/Http/Client/Adapter/Socket.php

@@ -339,14 +339,14 @@ class Zend_Http_Client_Adapter_Socket implements Zend_Http_Client_Adapter_Interf
 
                     // Convert the hexadecimal value to plain integer
                     $chunksize = hexdec($chunksize);
-                    
+
                     // Read next chunk
                     $read_to = ftell($this->socket) + $chunksize;
-                    
+
                     do {
                         $current_pos = ftell($this->socket);
                         if ($current_pos >= $read_to) break;
-                        
+
                         $line = @fread($this->socket, $read_to - $current_pos);
                         if ($line === false || strlen($line) === 0) {
                             $this->_checkSocketReadTimeout();
@@ -374,17 +374,17 @@ class Zend_Http_Client_Adapter_Socket implements Zend_Http_Client_Adapter_Interf
 
             $current_pos = ftell($this->socket);
             $chunk = '';
-            
+
             for ($read_to = $current_pos + $headers['content-length'];
                  $read_to > $current_pos;
                  $current_pos = ftell($this->socket)) {
-                     
+
                 $chunk = @fread($this->socket, $read_to - $current_pos);
                 if ($chunk === false || strlen($chunk) === 0) {
                     $this->_checkSocketReadTimeout();
                     break;
-                } 
-                
+                }
+
                 $response .= $chunk;
 
                 // Break if the connection ended prematurely

+ 14 - 14
library/Zend/Http/Cookie.php

@@ -240,7 +240,7 @@ class Zend_Http_Cookie
         if (! self::matchCookieDomain($this->getDomain(), $uri->getHost())) {
             return false;
         }
-        
+
         // Check that path matches using prefix match
         if (! self::matchCookiePath($this->getPath(), $uri->getPath())) {
             return false;
@@ -350,12 +350,12 @@ class Zend_Http_Cookie
 
     /**
      * Check if a cookie's domain matches a host name.
-     * 
+     *
      * Used by Zend_Http_Cookie and Zend_Http_CookieJar for cookie matching
-     * 
+     *
      * @param  string $cookieDomain
      * @param  string $host
-     * 
+     *
      * @return boolean
      */
     public static function matchCookieDomain($cookieDomain, $host)
@@ -364,29 +364,29 @@ class Zend_Http_Cookie
             require_once 'Zend/Http/Exception.php';
             throw new Zend_Http_Exception("\$cookieDomain is expected to be a cookie domain");
         }
-        
+
         if (! $host) {
             require_once 'Zend/Http/Exception.php';
             throw new Zend_Http_Exception("\$host is expected to be a host name");
         }
-        
+
         $cookieDomain = strtolower($cookieDomain);
         $host = strtolower($host);
-        
+
         if ($cookieDomain[0] == '.') {
             $cookieDomain = substr($cookieDomain, 1);
         }
-        
+
         // Check for either exact match or suffix match
-        return ($cookieDomain == $host || 
+        return ($cookieDomain == $host ||
                 preg_match("/\.$cookieDomain$/", $host));
     }
 
     /**
      * Check if a cookie's path matches a URL path
-     * 
+     *
      * Used by Zend_Http_Cookie and Zend_Http_CookieJar for cookie matching
-     * 
+     *
      * @param  string $cookiePath
      * @param  string $path
      * @return boolean
@@ -397,12 +397,12 @@ class Zend_Http_Cookie
             require_once 'Zend/Http/Exception.php';
             throw new Zend_Http_Exception("\$cookiePath is expected to be a cookie path");
         }
-        
+
         if (! $path) {
             require_once 'Zend/Http/Exception.php';
             throw new Zend_Http_Exception("\$path is expected to be a host name");
         }
-        
-        return (strpos($path, $cookiePath) === 0);        
+
+        return (strpos($path, $cookiePath) === 0);
     }
 }

+ 3 - 3
library/Zend/Http/CookieJar.php

@@ -303,7 +303,7 @@ class Zend_Http_CookieJar implements Countable, IteratorAggregate
      * @param string $domain
      * @return array
      */
-    protected function _matchDomain($domain) 
+    protected function _matchDomain($domain)
     {
         $ret = array();
 
@@ -323,7 +323,7 @@ class Zend_Http_CookieJar implements Countable, IteratorAggregate
      * @param string $path
      * @return array
      */
-    protected function _matchPath($domains, $path) 
+    protected function _matchPath($domains, $path)
     {
         $ret = array();
 
@@ -333,7 +333,7 @@ class Zend_Http_CookieJar implements Countable, IteratorAggregate
                     if (! isset($ret[$dom])) {
                         $ret[$dom] = array();
                     }
-                    
+
                     $ret[$dom][$cpath] = $paths_array[$cpath];
                 }
             }

+ 11 - 11
library/Zend/Http/Response.php

@@ -561,15 +561,15 @@ class Zend_Http_Response
     {
         $decBody = '';
 
-        // If mbstring overloads substr and strlen functions, we have to 
+        // If mbstring overloads substr and strlen functions, we have to
         // override it's internal encoding
-        if (function_exists('mb_internal_encoding') && 
+        if (function_exists('mb_internal_encoding') &&
            ((int) ini_get('mbstring.func_overload')) & 2) {
 
             $mbIntEnc = mb_internal_encoding();
             mb_internal_encoding('ASCII');
         }
-        
+
         while (trim($body)) {
             if (! preg_match("/^([\da-fA-F]+)[^\r\n]*\r\n/sm", $body, $m)) {
                 require_once 'Zend/Http/Exception.php';
@@ -581,7 +581,7 @@ class Zend_Http_Response
             $decBody .= substr($body, $cut, $length);
             $body = substr($body, $cut + $length + 2);
         }
-        
+
         if (isset($mbIntEnc)) {
             mb_internal_encoding($mbIntEnc);
         }
@@ -627,21 +627,21 @@ class Zend_Http_Response
         }
 
         /**
-         * Some servers (IIS ?) send a broken deflate response, without the 
-         * RFC-required zlib header. 
-         * 
-         * We try to detect the zlib header, and if it does not exsit we 
+         * Some servers (IIS ?) send a broken deflate response, without the
+         * RFC-required zlib header.
+         *
+         * We try to detect the zlib header, and if it does not exsit we
          * teat the body is plain DEFLATE content.
-         * 
+         *
          * This method was adapted from PEAR HTTP_Request2 by (c) Alexey Borzov
-         * 
+         *
          * @link http://framework.zend.com/issues/browse/ZF-6040
          */
         $zlibHeader = unpack('n', substr($body, 0, 2));
         if ($zlibHeader[1] % 31 == 0) {
             return gzuncompress($body);
         } else {
-            return gzinflate($body); 
+            return gzinflate($body);
         }
     }
 

+ 3 - 3
tests/Zend/Http/Client/ProxyAdapterTest.php

@@ -69,17 +69,17 @@ class Zend_Http_Client_ProxyAdapterTest extends Zend_Http_Client_SocketTest
             $this->markTestSkipped("Zend_Http_Client proxy server tests are not enabled in TestConfiguration.php");
         }
     }
-    
+
     /**
      * Test that when no proxy is set the adapter falls back to direct connection
-     * 
+     *
      */
     public function testFallbackToSocket()
     {
         $this->_adapter->setConfig(array(
             'proxy_host' => null,
         ));
-        
+
         $this->client->setUri($this->baseuri . 'testGetLastRequest.php');
         $res = $this->client->request(Zend_Http_Client::TRACE);
         if ($res->getStatus() == 405 || $res->getStatus() == 501) {

+ 5 - 5
tests/Zend/Http/Client/SocketTest.php

@@ -193,17 +193,17 @@ class Zend_Http_Client_SocketTest extends Zend_Http_Client_CommonHttpTests
 
     /**
      * Test that a chunked response with multibyte characters is properly read
-     * 
-     * This can fail in various PHP environments - for example, when mbstring 
-     * overloads substr() and strlen(), and mbstring's internal encoding is 
-     * not a single-byte encoding. 
+     *
+     * This can fail in various PHP environments - for example, when mbstring
+     * overloads substr() and strlen(), and mbstring's internal encoding is
+     * not a single-byte encoding.
      *
      * @link http://framework.zend.com/issues/browse/ZF-6218
      */
     public function testMultibyteChunkedResponseZF6218()
     {
         $md5 = '7667818873302f9995be3798d503d8d3';
-        
+
         $response = $this->client->request();
         $this->assertEquals($md5, md5($response->getBody()));
     }

+ 9 - 9
tests/Zend/Http/Client/StaticTest.php

@@ -486,12 +486,12 @@ class Zend_Http_Client_StaticTest extends PHPUnit_Framework_TestCase
     }
 
     /**
-     * Test that we properly calculate the content-length of multibyte-encoded 
+     * Test that we properly calculate the content-length of multibyte-encoded
      * request body
-     * 
-     * This may file in case that mbstring overloads the substr and strlen 
-     * functions, and the mbstring internal encoding is a multibyte encoding. 
-     * 
+     *
+     * This may file in case that mbstring overloads the substr and strlen
+     * functions, and the mbstring internal encoding is a multibyte encoding.
+     *
      * @link http://framework.zend.com/issues/browse/ZF-2098
      */
     public function testMultibyteRawPostDataZF2098()
@@ -500,18 +500,18 @@ class Zend_Http_Client_StaticTest extends PHPUnit_Framework_TestCase
         $this->_client->setUri('http://example.com');
 
         $bodyFile = dirname(__FILE__) . '/_files/ZF2098-multibytepostdata.txt';
-        
+
         $this->_client->setRawData(file_get_contents($bodyFile), 'text/plain');
         $this->_client->request('POST');
         $request = $this->_client->getLastRequest();
-        
+
         if (! preg_match('/^content-length:\s+(\d+)/mi', $request, $match)) {
             $this->fail("Unable to find content-length header in request");
         }
-        
+
         $this->assertEquals(filesize($bodyFile), (int) $match[1]);
     }
-    
+
     /**
      * Data providers
      */

+ 4 - 4
tests/Zend/Http/CookieJarTest.php

@@ -90,7 +90,7 @@ class Zend_Http_CookieJarTest extends PHPUnit_Framework_TestCase
 
     /**
      * Test we get an exception in case of invalid response objects
-     * 
+     *
      * @dataProvider invalidResponseProvider
      * @expectedException Zend_Http_Exception
      */
@@ -99,7 +99,7 @@ class Zend_Http_CookieJarTest extends PHPUnit_Framework_TestCase
         $jar = new Zend_Http_Cookiejar();
         $jar->addCookiesFromResponse($resp, 'http://www.example.com');
     }
-    
+
     static public function invalidResponseProvider()
     {
         return array(
@@ -257,7 +257,7 @@ class Zend_Http_CookieJarTest extends PHPUnit_Framework_TestCase
 
     /**
      * Test we can get all matching cookies for a request, with session cookies
-     * 
+     *
      * @dataProvider cookieMatchTestProvider
      */
     public function testGetMatchingCookies($url, $expected)
@@ -279,7 +279,7 @@ class Zend_Http_CookieJarTest extends PHPUnit_Framework_TestCase
         $cookies = $jar->getMatchingCookies($url);
         $this->assertEquals($expected, count($cookies), $jar->getMatchingCookies($url, true, Zend_Http_CookieJar::COOKIE_STRING_CONCAT));
     }
-    
+
     static public function cookieMatchTestProvider()
     {
         return array(

+ 2 - 2
tests/Zend/Http/CookieTest.php

@@ -291,11 +291,11 @@ class Zend_Http_CookieTest extends PHPUnit_Framework_TestCase
         $cookie = Zend_Http_Cookie::fromString($cookieStr);
         $this->assertEquals($match, $cookie->match($uri));
     }
-    
+
     static public function domainMatchTestProvider()
     {
         $uri = Zend_Uri::factory('http://www.foo.com/some/file.txt');
-        
+
         return array(
             array('foo=bar; domain=.example.com;', 'http://www.example.com/foo/bar.php', true),
             array('foo=bar; domain=.example.com;', 'http://example.com/foo/bar.php', true),

+ 9 - 9
tests/Zend/Http/ResponseTest.php

@@ -59,14 +59,14 @@ class Zend_Http_ResponseTest extends PHPUnit_Framework_TestCase
         $this->assertEquals('0b13cb193de9450aa70a6403e2c9902f', md5($res->getBody()));
         $this->assertEquals('ad62c21c3aa77b6a6f39600f6dd553b8', md5($res->getRawBody()));
     }
-    
+
     /**
-     * Make sure wer can handle non-RFC complient "deflate" responses. 
-     * 
+     * Make sure wer can handle non-RFC complient "deflate" responses.
+     *
      * Unlike stanrdard 'deflate' response, those do not contain the zlib header
-     * and trailer. Unfortunately some buggy servers (read: IIS) send those and 
+     * and trailer. Unfortunately some buggy servers (read: IIS) send those and
      * we need to support them.
-     * 
+     *
      * @link http://framework.zend.com/issues/browse/ZF-6040
      */
     public function testNonStandardDeflateResponseZF6040()
@@ -293,13 +293,13 @@ class Zend_Http_ResponseTest extends PHPUnit_Framework_TestCase
         $body = Zend_Http_Response::extractBody($this->readResponse('response_leadingws'));
         $this->assertEquals($body, "\r\n\t  \n\r\tx", 'Extracted body is not identical to expected body');
     }
-    
+
     /**
      * Test that parsing a multibyte-encoded chunked response works.
-     * 
-     * This can potentially fail on different PHP environments - for example 
+     *
+     * This can potentially fail on different PHP environments - for example
      * when mbstring.func_overload is set to overload strlen().
-     * 
+     *
      */
     public function testMultibyteChunkedResponse()
     {