فهرست منبع

Fixing coding standard issues (tabs, linebreaks, trailing spaces) on Zend_Http stuff (ZF-7316)

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@17010 44c647ce-9c0f-0410-b52a-842ac1e357ba
shahar 16 سال پیش
والد
کامیت
d9ee9daf7e

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

@@ -223,14 +223,14 @@ class Zend_Http_Client
 
     /**
      * Fileinfo magic database resource
-     * 
+     *
      * This varaiable is populated the first time _detectFileMimeType is called
      * and is then reused on every call to this method
      *
      * @var resource
      */
     static protected $_fileInfoDb = null;
-    
+
     /**
      * Contructor method. Will create a new HTTP client. Accepts the target
      * URL and optionally configuration array.
@@ -314,7 +314,7 @@ class Zend_Http_Client
         if ($this->adapter instanceof Zend_Http_Client_Adapter_Interface) {
             $this->adapter->setConfig($config);
         }
-        
+
         return $this;
     }
 
@@ -388,7 +388,7 @@ class Zend_Http_Client
                 require_once 'Zend/Http/Client/Exception.php';
                 throw new Zend_Http_Client_Exception("{$name} is not a valid HTTP header name");
             }
-            
+
             $normalized_name = strtolower($name);
 
             // If $value is null or false, unset the header
@@ -692,9 +692,9 @@ class Zend_Http_Client
         $this->setEncType(self::ENC_FORMDATA);
 
         $this->files[] = array(
-            'formname' => $formname, 
-            'filename' => basename($filename), 
-            'ctype'    => $ctype, 
+            'formname' => $formname,
+            'filename' => basename($filename),
+            'ctype'    => $ctype,
             'data'     => $data
         );
 
@@ -980,14 +980,14 @@ class Zend_Http_Client
                 $headers[] = 'Accept-encoding: identity';
             }
         }
-        
+
         // Set the Content-Type header
         if ($this->method == self::POST &&
            (! isset($this->headers[strtolower(self::CONTENT_TYPE)]) && isset($this->enctype))) {
 
             $headers[] = self::CONTENT_TYPE . ': ' . $this->enctype;
         }
-        
+
         // Set the user agent header
         if (! isset($this->headers['user-agent']) && isset($this->config['useragent'])) {
             $headers[] = "User-Agent: {$this->config['useragent']}";
@@ -1085,7 +1085,7 @@ class Zend_Http_Client
                     break;
             }
         }
-        
+
         // Set the Content-Length if we have a body or if request is POST/PUT
         if ($body || $this->method == self::POST || $this->method == self::PUT) {
             $this->setHeaders(self::CONTENT_LENGTH, strlen($body));
@@ -1102,11 +1102,11 @@ class Zend_Http_Client
      * necessarily unique. If one of the parameters in as array, it will also
      * add a [] suffix to the key.
      *
-     * This method is deprecated since Zend Framework 1.9 in favour of 
+     * This method is deprecated since Zend Framework 1.9 in favour of
      * self::_flattenParametersArray() and will be dropped in 2.0
-     * 
+     *
      * @deprecated since 1.9
-     * 
+     *
      * @param  array $parray    The parameters array
      * @param  bool  $urlencode Whether to urlencode the name and value
      * @return array
@@ -1114,9 +1114,9 @@ class Zend_Http_Client
     protected function _getParametersRecursive($parray, $urlencode = false)
     {
         // Issue a deprecated notice
-        trigger_error("The " .  __METHOD__ . " method is deprecated and will be dropped in 2.0.", 
+        trigger_error("The " .  __METHOD__ . " method is deprecated and will be dropped in 2.0.",
             E_USER_NOTICE);
-            
+
         if (! is_array($parray)) {
             return $parray;
         }
@@ -1146,15 +1146,15 @@ class Zend_Http_Client
 
         return $parameters;
     }
-    
+
     /**
      * Attempt to detect the MIME type of a file using available extensions
-     * 
+     *
      * This method will try to detect the MIME type of a file. If the fileinfo
-     * extension is available, it will be used. If not, the mime_magic 
+     * extension is available, it will be used. If not, the mime_magic
      * extension which is deprected but is still available in many PHP setups
-     * will be tried. 
-     * 
+     * will be tried.
+     *
      * If neither extension is available, the default application/octet-stream
      * MIME type will be returned
      *
@@ -1164,26 +1164,26 @@ class Zend_Http_Client
     protected function _detectFileMimeType($file)
     {
         $type = null;
-        
+
         // First try with fileinfo functions
         if (function_exists('finfo_open')) {
             if (self::$_fileInfoDb === null) {
                 self::$_fileInfoDb = @finfo_open(FILEINFO_MIME);
             }
-            
-            if (self::$_fileInfoDb) { 
+
+            if (self::$_fileInfoDb) {
                 $type = finfo_file(self::$_fileInfoDb, $file);
             }
-            
+
         } elseif (function_exists('mime_content_type')) {
             $type = mime_content_type($file);
         }
-        
+
         // Fallback to the default application/octet-stream
         if (! $type) {
             $type = 'application/octet-stream';
         }
-        
+
         return $type;
     }
 
@@ -1260,14 +1260,14 @@ class Zend_Http_Client
 
     /**
      * Convert an array of parameters into a flat array of (key, value) pairs
-     * 
-     * Will flatten a potentially multi-dimentional array of parameters (such 
-     * as POST parameters) into a flat array of (key, value) paris. In case 
+     *
+     * Will flatten a potentially multi-dimentional array of parameters (such
+     * as POST parameters) into a flat array of (key, value) paris. In case
      * of multi-dimentional arrays, square brackets ([]) will be added to the
-     * key to indicate an array. 
-     * 
+     * key to indicate an array.
+     *
      * @since  1.9
-     * 
+     *
      * @param  array  $parray
      * @param  string $prefix
      * @return array
@@ -1277,11 +1277,11 @@ class Zend_Http_Client
         if (! is_array($parray)) {
             return $parray;
         }
-        
+
         $parameters = array();
-        
+
         foreach($parray as $name => $value) {
-            
+
             // Calculate array key
             if ($prefix) {
                 if (is_int($name)) {
@@ -1292,16 +1292,16 @@ class Zend_Http_Client
             } else {
                 $key = $name;
             }
-            
+
             if (is_array($value)) {
                 $parameters = array_merge($parameters, self::_flattenParametersArray($value, $key));
-                
+
             } else {
                 $parameters[] = array($key, $value);
             }
         }
-        
+
         return $parameters;
     }
-    
+
 }

+ 5 - 5
library/Zend/Http/Client/Adapter/Curl.php

@@ -62,7 +62,7 @@ class Zend_Http_Client_Adapter_Curl implements Zend_Http_Client_Adapter_Interfac
 
     /**
      * List of cURL options that should never be overwritten
-     * 
+     *
      * @var array
      */
     protected $_invalidOverwritableCurlOptions = array(
@@ -145,7 +145,7 @@ class Zend_Http_Client_Adapter_Curl implements Zend_Http_Client_Adapter_Interfac
 
     /**
      * Direct setter for cURL adapter related options.
-     * 
+     *
      * @param  string|int $option
      * @param  mixed $value
      * @return Zend_Http_Adapter_Curl
@@ -176,9 +176,9 @@ class Zend_Http_Client_Adapter_Curl implements Zend_Http_Client_Adapter_Interfac
         }
 
         // If we are connected to a different server or port, disconnect first
-        if ($this->_curl 
-            && is_array($this->_connected_to) 
-            && ($this->_connected_to[0] != $host 
+        if ($this->_curl
+            && is_array($this->_connected_to)
+            && ($this->_connected_to[0] != $host
             || $this->_connected_to[1] != $port)
         ) {
             $this->close();

+ 17 - 17
library/Zend/Http/Client/Adapter/Proxy.php

@@ -72,7 +72,7 @@ class Zend_Http_Client_Adapter_Proxy extends Zend_Http_Client_Adapter_Socket
      * @var boolean
      */
     protected $negotiated = false;
-    
+
     /**
      * Connect to the remote server
      *
@@ -154,13 +154,13 @@ class Zend_Http_Client_Adapter_Proxy extends Zend_Http_Client_Adapter_Socket
                 $this->config['proxy_user'], $this->config['proxy_pass'], $this->config['proxy_auth']
             );
         }
-                
+
         // if we are proxying HTTPS, preform CONNECT handshake with the proxy
         if ($uri->getScheme() == 'https' && (! $this->negotiated)) {
             $this->connectHandshake($uri->getHost(), $uri->getPort(), $http_ver, $headers);
             $this->negotiated = true;
         }
-        
+
         // Save request method for later
         $this->method = $method;
 
@@ -195,21 +195,21 @@ class Zend_Http_Client_Adapter_Proxy extends Zend_Http_Client_Adapter_Socket
      */
     protected function connectHandshake($host, $port = 443, $http_ver = '1.1', array &$headers = array())
     {
-        $request = "CONNECT $host:$port HTTP/$http_ver\r\n" . 
+        $request = "CONNECT $host:$port HTTP/$http_ver\r\n" .
                    "Host: " . $this->config['proxy_host'] . "\r\n";
 
         // Add the user-agent header
         if (isset($this->config['useragent'])) {
             $request .= "User-agent: " . $this->config['useragent'] . "\r\n";
         }
-        
+
         // If the proxy-authorization header is set, send it to proxy but remove
         // it from headers sent to target host
         if (isset($headers['proxy-authorization'])) {
             $request .= "Proxy-authorization: " . $headers['proxy-authorization'] . "\r\n";
             unset($headers['proxy-authorization']);
         }
-    
+
         $request .= "\r\n";
 
         // Send the request
@@ -228,35 +228,35 @@ class Zend_Http_Client_Adapter_Proxy extends Zend_Http_Client_Adapter_Socket
                 if (!chop($line)) break;
             }
         }
-        
+
         // Check that the response from the proxy is 200
         if (Zend_Http_Response::extractCode($response) != 200) {
             require_once 'Zend/Http/Client/Adapter/Exception.php';
             throw new Zend_Http_Client_Adapter_Exception("Unable to connect to HTTPS proxy. Server response: " . $response);
         }
-        
+
         // If all is good, switch socket to secure mode. We have to fall back
-        // through the different modes 
+        // through the different modes
         $modes = array(
-            STREAM_CRYPTO_METHOD_TLS_CLIENT, 
+            STREAM_CRYPTO_METHOD_TLS_CLIENT,
             STREAM_CRYPTO_METHOD_SSLv3_CLIENT,
             STREAM_CRYPTO_METHOD_SSLv23_CLIENT,
-            STREAM_CRYPTO_METHOD_SSLv2_CLIENT 
+            STREAM_CRYPTO_METHOD_SSLv2_CLIENT
         );
-        
-        $success = false; 
+
+        $success = false;
         foreach($modes as $mode) {
             $success = stream_socket_enable_crypto($this->socket, true, $mode);
             if ($success) break;
         }
-        
+
         if (! $success) {
                 require_once 'Zend/Http/Client/Adapter/Exception.php';
-                throw new Zend_Http_Client_Adapter_Exception("Unable to connect to" . 
+                throw new Zend_Http_Client_Adapter_Exception("Unable to connect to" .
                     " HTTPS server through proxy: could not negotiate secure connection.");
         }
     }
-    
+
     /**
      * Close the connection to the server
      *
@@ -266,7 +266,7 @@ class Zend_Http_Client_Adapter_Proxy extends Zend_Http_Client_Adapter_Socket
         parent::close();
         $this->negotiated = false;
     }
-    
+
     /**
      * Destructor: make sure the socket is disconnected
      *

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

@@ -77,11 +77,11 @@ class Zend_Http_Client_Adapter_Socket implements Zend_Http_Client_Adapter_Interf
 
     /**
      * Stream context
-     * 
+     *
      * @var resource
      */
     protected $_context = null;
-    
+
     /**
      * Adapter constructor, currently empty. Config is set using setConfig()
      *
@@ -107,17 +107,17 @@ class Zend_Http_Client_Adapter_Socket implements Zend_Http_Client_Adapter_Interf
             $this->config[strtolower($k)] = $v;
         }
     }
-    
+
     /**
      * Set the stream context for the TCP connection to the server
-     * 
+     *
      * Can accept either a pre-existing stream context resource, or an array
-     * of stream options, similar to the options array passed to the 
+     * of stream options, similar to the options array passed to the
      * stream_context_create() PHP function. In such case a new stream context
      * will be created using the passed options.
-     * 
+     *
      * @since  Zend Framework 1.9
-     * 
+     *
      * @param  mixed $context Stream context or array of context options
      * @return Zend_Http_Client_Adapter_Socket
      */
@@ -125,10 +125,10 @@ class Zend_Http_Client_Adapter_Socket implements Zend_Http_Client_Adapter_Interf
     {
         if (is_resource($context) && get_resource_type($context) == 'stream-context') {
             $this->_context = $context;
-            
+
         } elseif (is_array($context)) {
             $this->_context = stream_context_create($context);
-            
+
         } else {
             // Invalid parameter
             require_once 'Zend/Http/Client/Adapter/Exception.php';
@@ -136,15 +136,15 @@ class Zend_Http_Client_Adapter_Socket implements Zend_Http_Client_Adapter_Interf
                 "Expecting either a stream context resource or array, got " . gettype($context)
             );
         }
-        
+
         return $this;
     }
-    
+
     /**
-     * Get the stream context for the TCP connection to the server. 
-     * 
-     * If no stream context is set, will create a default one. 
-     * 
+     * Get the stream context for the TCP connection to the server.
+     *
+     * If no stream context is set, will create a default one.
+     *
      * @return resource
      */
     public function getStreamContext()
@@ -152,7 +152,7 @@ class Zend_Http_Client_Adapter_Socket implements Zend_Http_Client_Adapter_Interf
         if (! $this->_context) {
             $this->_context = stream_context_create();
         }
-        
+
         return $this->_context;
     }
 
@@ -203,7 +203,7 @@ class Zend_Http_Client_Adapter_Socket implements Zend_Http_Client_Adapter_Interf
                                                   (int) $this->config['timeout'],
                                                   $flags,
                                                   $context);
-                                                  
+
             if (! $this->socket) {
                 $this->close();
                 require_once 'Zend/Http/Client/Adapter/Exception.php';
@@ -368,15 +368,15 @@ class Zend_Http_Client_Adapter_Socket implements Zend_Http_Client_Adapter_Interf
 
         // Fallback: just read the response until EOF
         } else {
-        	do {
-        		$buff = @fread($this->socket, 8192);
-        		if ($buff === false || strlen($buff) === 0)
-        		{
-        			break;
-        		} else {
+            do {
+                $buff = @fread($this->socket, 8192);
+                if ($buff === false || strlen($buff) === 0)
+                {
+                    break;
+                } else {
                     $response .= $buff;
-        		}
-        	} while (feof($this->socket) === false);
+                }
+            } while (feof($this->socket) === false);
 
             $this->close();
         }

+ 2 - 2
library/Zend/Http/Client/Adapter/Test.php

@@ -181,10 +181,10 @@ class Zend_Http_Client_Adapter_Test implements Zend_Http_Client_Adapter_Interfac
      */
     public function addResponse($response)
     {
-     	if ($response instanceof Zend_Http_Response) {
+         if ($response instanceof Zend_Http_Response) {
             $response = $response->asString("\r\n");
         }
-        
+
         $this->responses[] = $response;
     }
 

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

@@ -314,24 +314,24 @@ class Zend_Http_Cookie
                              * The expiration is past Tue, 19 Jan 2038 03:14:07 UTC
                              * the maximum for 32-bit signed integer. Zend_Date
                              * can get around that limit.
-                             * 
+                             *
                              * @see Zend_Date
                              */
                             require_once 'Zend/Date.php';
-    
+
                             $expireDate = new Zend_Date($v);
                             $expires = $expireDate->getTimestamp();
                         }
                         break;
-                        
+
                     case 'path':
                         $path = $v;
                         break;
-                        
+
                     case 'domain':
                         $domain = $v;
                         break;
-                        
+
                     default:
                         break;
                 }

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

@@ -50,14 +50,14 @@ require_once "Zend/Http/Response.php";
  * (by passing Zend_Http_CookieJar::COOKIE_STRING_CONCAT).
  *
  * @link       http://wp.netscape.com/newsref/std/cookie_spec.html for some specs.
- * 
+ *
  * @category   Zend
  * @package    Zend_Http
  * @subpackage CookieJar
  * @copyright  Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
-class Zend_Http_CookieJar implements Countable, IteratorAggregate 
+class Zend_Http_CookieJar implements Countable, IteratorAggregate
 {
     /**
      * Return cookie(s) as a Zend_Http_Cookie object
@@ -146,7 +146,7 @@ class Zend_Http_CookieJar implements Countable, IteratorAggregate
     public function addCookiesFromResponse($response, $ref_uri)
     {
         if (! $response instanceof Zend_Http_Response) {
-            require_once 'Zend/Http/Exception.php';        
+            require_once 'Zend/Http/Exception.php';
             throw new Zend_Http_Exception('$response is expected to be a Response object, ' .
                 gettype($response) . ' was passed');
         }
@@ -190,7 +190,7 @@ class Zend_Http_CookieJar implements Countable, IteratorAggregate
     {
         if (is_string($uri)) $uri = Zend_Uri::factory($uri);
         if (! $uri instanceof Zend_Uri_Http) {
-            require_once 'Zend/Http/Exception.php';    
+            require_once 'Zend/Http/Exception.php';
             throw new Zend_Http_Exception("Invalid URI string or object passed");
         }
 

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

@@ -493,11 +493,11 @@ class Zend_Http_Response
     public static function extractHeaders($response_str)
     {
         $headers = array();
-        
+
         // First, split body and headers
         $parts = preg_split('|(?:\r?\n){2}|m', $response_str, 2);
         if (! $parts[0]) return $headers;
-        
+
         // Split headers part to lines
         $lines = explode("\n", $parts[0]);
         unset($parts);
@@ -545,7 +545,7 @@ class Zend_Http_Response
     public static function extractBody($response_str)
     {
         $parts = preg_split('|(?:\r?\n){2}|m', $response_str, 2);
-        if (isset($parts[1])) { 
+        if (isset($parts[1])) {
             return $parts[1];
         }
         return '';
@@ -560,7 +560,7 @@ class Zend_Http_Response
     public static function decodeChunkedBody($body)
     {
         $decBody = '';
-        
+
         while (trim($body)) {
             if (! preg_match("/^([\da-fA-F]+)[^\r\n]*\r\n/sm", $body, $m)) {
                 require_once 'Zend/Http/Exception.php';
@@ -589,8 +589,8 @@ class Zend_Http_Response
     {
         if (! function_exists('gzinflate')) {
             require_once 'Zend/Http/Exception.php';
-            throw new Zend_Http_Exception('Unable to decode gzipped response ' . 
-                'body: perhaps the zlib extension is not loaded?'); 
+            throw new Zend_Http_Exception('Unable to decode gzipped response ' .
+                'body: perhaps the zlib extension is not loaded?');
         }
 
         return gzinflate(substr($body, 10));
@@ -608,8 +608,8 @@ class Zend_Http_Response
     {
         if (! function_exists('gzuncompress')) {
             require_once 'Zend/Http/Exception.php';
-            throw new Zend_Http_Exception('Unable to decode deflated response ' . 
-                'body: perhaps the zlib extension is not loaded?'); 
+            throw new Zend_Http_Exception('Unable to decode deflated response ' .
+                'body: perhaps the zlib extension is not loaded?');
         }
 
         return gzuncompress($body);

+ 19 - 19
tests/Zend/Http/Client/CommonHttpTests.php

@@ -71,13 +71,13 @@ abstract class Zend_Http_Client_CommonHttpTests extends PHPUnit_Framework_TestCa
 
             $this->baseuri = TESTS_ZEND_HTTP_CLIENT_BASEURI;
             if (substr($this->baseuri, -1) != '/') $this->baseuri .= '/';
-            
+
             $name = $this->getName();
             if (($pos = strpos($name, ' ')) !== false) {
                 $name = substr($name, 0, $pos);
             }
-            
-            $uri = $this->baseuri . $name . '.php'; 
+
+            $uri = $this->baseuri . $name . '.php';
             $this->client = new Zend_Http_Client($uri, $this->config);
 
         } else {
@@ -85,10 +85,10 @@ abstract class Zend_Http_Client_CommonHttpTests extends PHPUnit_Framework_TestCa
             $this->markTestSkipped("Zend_Http_Client dynamic tests are not enabled in TestConfiguration.php");
         }
     }
-    
+
     /**
      * Clean up the test environment
-     * 
+     *
      */
     protected function tearDown()
     {
@@ -278,7 +278,7 @@ abstract class Zend_Http_Client_CommonHttpTests extends PHPUnit_Framework_TestCa
         if ($res->getStatus() == 405 || $res->getStatus() == 501) {
             $this->markTestSkipped("Server does not allow the TRACE method");
         }
-        
+
         $body = strtolower($res->getBody());
 
         foreach ($headers as $key => $val)
@@ -308,7 +308,7 @@ abstract class Zend_Http_Client_CommonHttpTests extends PHPUnit_Framework_TestCa
         if ($res->getStatus() == 405 || $res->getStatus() == 501) {
             $this->markTestSkipped("Server does not allow the TRACE method");
         }
-        
+
         $body = strtolower($res->getBody());
 
         foreach ($headers as $key => $val) {
@@ -733,7 +733,7 @@ abstract class Zend_Http_Client_CommonHttpTests extends PHPUnit_Framework_TestCa
     }
 
     /**
-     * Test that one can upload multiple files with the same form name, as an 
+     * Test that one can upload multiple files with the same form name, as an
      * array
      *
      * @link http://framework.zend.com/issues/browse/ZF-5744
@@ -741,22 +741,22 @@ abstract class Zend_Http_Client_CommonHttpTests extends PHPUnit_Framework_TestCa
     public function testMutipleFilesWithSameFormNameZF5744()
     {
         $rawData = 'Some test raw data here...';
-        
+
         $this->client->setUri($this->baseuri . 'testUploads.php');
-        
+
         $files = array('file1.txt', 'file2.txt', 'someotherfile.foo');
-        
+
         $expectedBody = '';
         foreach($files as $filename) {
             $this->client->setFileUpload($filename, 'uploadfile[]', $rawData, 'text/plain');
             $expectedBody .= "uploadfile $filename text/plain " . strlen($rawData) . "\n";
         }
-        
+
         $res = $this->client->request('POST');
 
         $this->assertEquals($expectedBody, $res->getBody(), 'Response body does not include expected upload parameters');
     }
-    
+
     /**
      * Test that lines that might be evaluated as boolean false do not break
      * the reading prematurely.
@@ -786,7 +786,7 @@ abstract class Zend_Http_Client_CommonHttpTests extends PHPUnit_Framework_TestCa
 
     /**
      * Data provider for complex, nesting parameter arrays
-     * 
+     *
      * @return array
      */
     static public function parameterArrayProvider()
@@ -800,12 +800,12 @@ abstract class Zend_Http_Client_CommonHttpTests extends PHPUnit_Framework_TestCa
                     'array' => array('firstItem', 'secondItem', '3rdItem')
                 )
             ),
-            
+
             array(
                 array(
                     'someData' => array(
-                        "1", 
-                        "2", 
+                        "1",
+                        "2",
                         'key' => 'value',
                         'nesting' => array(
                             'a' => 'AAA',
@@ -815,12 +815,12 @@ abstract class Zend_Http_Client_CommonHttpTests extends PHPUnit_Framework_TestCa
                     'someOtherData' => array('foo', 'bar')
                 )
             ),
-            
+
             array(
                 array(
                     'foo1' => 'bar',
                     'foo2' => array('baz', 'w00t')
-                ) 
+                )
             )
         );
     }

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

@@ -21,61 +21,61 @@ require_once 'Zend/Http/Client/Adapter/Proxy.php';
  */
 class Zend_Http_Client_ProxyAdapterTest extends Zend_Http_Client_SocketTest
 {
-	/**
-	 * Configuration array
-	 *
-	 * @var array
-	 */
-	protected function setUp()
-	{
-		if (defined('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY') &&
-		      TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY) {
+    /**
+     * Configuration array
+     *
+     * @var array
+     */
+    protected function setUp()
+    {
+        if (defined('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY') &&
+              TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY) {
 
-		    list($host, $port) = explode(':', TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY, 2);
+            list($host, $port) = explode(':', TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY, 2);
 
-		    if (! $host)
-		        $this->markTestSkipped("No valid proxy host name or address specified.");
+            if (! $host)
+                $this->markTestSkipped("No valid proxy host name or address specified.");
 
-		    $port = (int) $port;
-		    if ($port == 0) {
-		    	$port = 8080;
-		    } else {
-			    if (($port < 1 || $port > 65535))
-		    		$this->markTestSkipped("$port is not a valid proxy port number. Should be between 1 and 65535.");
-		    }
+            $port = (int) $port;
+            if ($port == 0) {
+                $port = 8080;
+            } else {
+                if (($port < 1 || $port > 65535))
+                    $this->markTestSkipped("$port is not a valid proxy port number. Should be between 1 and 65535.");
+            }
 
-		    $user = '';
-		    $pass = '';
-		    if (defined('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY_USER') &&
-		        TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY_USER)
-		            $user = TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY_USER;
+            $user = '';
+            $pass = '';
+            if (defined('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY_USER') &&
+                TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY_USER)
+                    $user = TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY_USER;
 
-		    if (defined('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY_PASS') &&
-		        TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY_PASS)
-		            $pass = TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY_PASS;
+            if (defined('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY_PASS') &&
+                TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY_PASS)
+                    $pass = TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY_PASS;
 
 
-		    $this->config = array(
-		        'adapter'    => 'Zend_Http_Client_Adapter_Proxy',
-		        'proxy_host' => $host,
-		        'proxy_port' => $port,
-		        'proxy_user' => $user,
-		        'proxy_pass' => $pass,
-		    );
+            $this->config = array(
+                'adapter'    => 'Zend_Http_Client_Adapter_Proxy',
+                'proxy_host' => $host,
+                'proxy_port' => $port,
+                'proxy_user' => $user,
+                'proxy_pass' => $pass,
+            );
 
-		    parent::setUp();
+            parent::setUp();
 
-		} else {
+        } else {
             $this->markTestSkipped("Zend_Http_Client proxy server tests are not enabled in TestConfiguration.php");
-		}
-	}
-	
-	public function testGetLastRequest()
-	{
-	    /**
-	     * This test will never work for the proxy adapter (and shouldn't!) 
-	     * because the proxy server modifies the request which is sent back in
-	     * the TRACE response
-	     */
-	}
+        }
+    }
+
+    public function testGetLastRequest()
+    {
+        /**
+         * This test will never work for the proxy adapter (and shouldn't!)
+         * because the proxy server modifies the request which is sent back in
+         * the TRACE response
+         */
+    }
 }

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

@@ -24,13 +24,13 @@ require_once dirname(__FILE__) . '/SocketTest.php';
  */
 class Zend_Http_Client_SocketKeepaliveTest extends Zend_Http_Client_SocketTest
 {
-	/**
-	 * Configuration array
-	 *
-	 * @var array
-	 */
-	protected $config = array(
-		'adapter'     => 'Zend_Http_Client_Adapter_Socket',
-		'keepalive'   => true
-	);
+    /**
+     * Configuration array
+     *
+     * @var array
+     */
+    protected $config = array(
+        'adapter'     => 'Zend_Http_Client_Adapter_Socket',
+        'keepalive'   => true
+    );
 }

+ 10 - 10
tests/Zend/Http/Client/SocketPersistentTest.php

@@ -24,14 +24,14 @@ require_once dirname(__FILE__) . '/SocketTest.php';
  */
 class Zend_Http_Client_SocketPersistentTest extends Zend_Http_Client_SocketTest
 {
-	/**
-	 * Configuration array
-	 *
-	 * @var array
-	 */
-	protected $config = array(
-		'adapter'    => 'Zend_Http_Client_Adapter_Socket',
-		'persistent' => true,
-	    'keepalive'  => true
-	);
+    /**
+     * Configuration array
+     *
+     * @var array
+     */
+    protected $config = array(
+        'adapter'    => 'Zend_Http_Client_Adapter_Socket',
+        'persistent' => true,
+        'keepalive'  => true
+    );
 }

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

@@ -34,29 +34,29 @@ class Zend_Http_Client_SocketTest extends Zend_Http_Client_CommonHttpTests
     protected $config = array(
         'adapter' => 'Zend_Http_Client_Adapter_Socket'
     );
-    
+
     /**
      * Stream context related tests
      */
-    
+
     public function testGetNewStreamContext()
     {
         $adapter = new $this->config['adapter'];
         $context = $adapter->getStreamContext();
-        
+
         $this->assertEquals('stream-context', get_resource_type($context));
     }
-    
+
     public function testSetNewStreamContextResource()
     {
         $adapter = new $this->config['adapter'];
         $context = stream_context_create();
-        
+
         $adapter->setStreamContext($context);
-        
+
         $this->assertEquals($context, $adapter->getStreamContext());
     }
-    
+
     public function testSetNewStreamContextOptions()
     {
         $adapter = new $this->config['adapter'];
@@ -69,15 +69,15 @@ class Zend_Http_Client_SocketTest extends Zend_Http_Client_CommonHttpTests
                 'allow_self_signed' => false
             )
         );
-        
+
         $adapter->setStreamContext($options);
-        
+
         $this->assertEquals($options, stream_context_get_options($adapter->getStreamContext()));
     }
-    
+
     /**
      * Test that setting invalid options / context causes an exception
-     * 
+     *
      * @dataProvider      invalidContextProvider
      * @expectedException Zend_Http_Client_Adapter_Exception
      */
@@ -86,13 +86,13 @@ class Zend_Http_Client_SocketTest extends Zend_Http_Client_CommonHttpTests
         $adapter = new $this->config['adapter'];
         $adapter->setStreamContext($invalid);
     }
-    
+
     public function testSetHttpsStreamContextParam()
     {
         if ($this->client->getUri()->getScheme() != 'https') {
             $this->markTestSkipped();
         }
-        
+
         $adapter = new $this->config['adapter'];
         $adapter->setStreamContext(array(
             'ssl' => array(
@@ -100,22 +100,22 @@ class Zend_Http_Client_SocketTest extends Zend_Http_Client_CommonHttpTests
                 'capture_peer_chain' => true
             )
         ));
-        
+
         $this->client->setAdapter($adapter);
         $this->client->setUri($this->baseuri . '/testSimpleRequests.php');
         $this->client->request();
-        
+
         $opts = stream_context_get_options($adapter->getStreamContext());
         $this->assertTrue(isset($opts['ssl']['peer_certificate']));
-    } 
-        
+    }
+
     /**
      * Data Providers
      */
-    
+
     /**
-     * Provide invalid context resources / options 
-     *  
+     * Provide invalid context resources / options
+     *
      * @return array
      */
     static public function invalidContextProvider()

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

@@ -39,13 +39,13 @@ class Zend_Http_Client_StaticTest extends PHPUnit_Framework_TestCase
 
     /**
      * Clean up after running a test
-     * 
+     *
      */
     public function tearDown()
     {
         $this->_client = null;
     }
-   
+
     /**
      * URI Tests
      */
@@ -120,15 +120,15 @@ class Zend_Http_Client_StaticTest extends PHPUnit_Framework_TestCase
     public function testDoubleGetParameter()
     {
         $qstr = 'foo=bar&foo=baz';
-        
+
         $this->_client->setUri('http://example.com/test/?' . $qstr);
         $this->_client->setAdapter('Zend_Http_Client_Adapter_Test');
-        
+
         $res = $this->_client->request('GET');
-        $this->assertContains($qstr, $this->_client->getLastRequest(), 
+        $this->assertContains($qstr, $this->_client->getLastRequest(),
             'Request is expected to contain the entire query string');
     }
-    
+
     /**
      * Header Tests
      */
@@ -282,18 +282,18 @@ class Zend_Http_Client_StaticTest extends PHPUnit_Framework_TestCase
     public function testGetLastResponse()
     {
         // First, make sure we get null before the request
-        $this->assertEquals(null, $this->_client->getLastResponse(), 
+        $this->assertEquals(null, $this->_client->getLastResponse(),
             'getLastResponse() is still expected to return null');
 
         // Now, test we get a proper response after the request
         $this->_client->setUri('http://example.com/foo/bar');
         $this->_client->setAdapter('Zend_Http_Client_Adapter_Test');
-        
+
         $response = $this->_client->request();
-        $this->assertTrue(($response === $this->_client->getLastResponse()), 
+        $this->assertTrue(($response === $this->_client->getLastResponse()),
             'Response is expected to be identical to the result of getLastResponse()');
     }
-    
+
     /**
      * Test that getLastResponse returns null when not storing
      *
@@ -304,17 +304,17 @@ class Zend_Http_Client_StaticTest extends PHPUnit_Framework_TestCase
         $this->_client->setUri('http://example.com/foo/bar');
         $this->_client->setAdapter('Zend_Http_Client_Adapter_Test');
         $this->_client->setConfig(array('storeresponse' => false));
-        
+
         $response = $this->_client->request();
 
-        $this->assertNull($this->_client->getLastResponse(), 
+        $this->assertNull($this->_client->getLastResponse(),
             'getLastResponse is expected to be null when not storing');
     }
-    
+
     /**
      * Check we get an exception when trying to send a POST request with an
      * invalid content-type header
-     * 
+     *
      * @expectedException Zend_Http_Client_Exception
      */
     public function testInvalidPostContentType()
@@ -331,11 +331,11 @@ class Zend_Http_Client_StaticTest extends PHPUnit_Framework_TestCase
      *
      * @expectedException Zend_Http_Client_Adapter_Exception
      */
-    public function testSocketErrorException() 
+    public function testSocketErrorException()
     {
         // Try to connect to an invalid host
         $this->_client->setUri('http://255.255.255.255');
-        
+
         // Reduce timeout to 3 seconds to avoid waiting
         $this->_client->setConfig(array('timeout' => 3));
 
@@ -345,7 +345,7 @@ class Zend_Http_Client_StaticTest extends PHPUnit_Framework_TestCase
 
     /**
      * Check that we can set methods which are not documented in the RFC.
-     * 
+     *
      * @dataProvider validMethodProvider
      */
     public function testSettingExtendedMethod($method)
@@ -358,7 +358,7 @@ class Zend_Http_Client_StaticTest extends PHPUnit_Framework_TestCase
     }
 
     /**
-     * Check that an exception is thrown if non-word characters are used in 
+     * Check that an exception is thrown if non-word characters are used in
      * the request method.
      *
      * @dataProvider invalidMethodProvider
@@ -390,18 +390,18 @@ class Zend_Http_Client_StaticTest extends PHPUnit_Framework_TestCase
         $adapterCfg = $this->getObjectAttribute($adapter, 'config');
         $this->assertEquals('value2', $adapterCfg['param']);
     }
-    
+
     /**
-     * Test that POST data with mutli-dimentional array is properly encoded as 
+     * Test that POST data with mutli-dimentional array is properly encoded as
      * multipart/form-data
-     * 
+     *
      */
     public function testFormDataEncodingWithMultiArrayZF7038()
     {
         $this->_client->setAdapter('Zend_Http_Client_Adapter_Test');
         $this->_client->setUri('http://example.com');
         $this->_client->setEncType(Zend_Http_Client::ENC_FORMDATA);
-        
+
         $this->_client->setParameterPost('test', array(
             'v0.1',
             'v0.2',
@@ -411,15 +411,15 @@ class Zend_Http_Client_StaticTest extends PHPUnit_Framework_TestCase
                 'k2.1' => 'v2.1.0'
             )
         ));
-        
+
         $this->_client->request('POST');
-        
+
         $expectedLines = file(dirname(__FILE__) . '/_files/ZF7038-multipartarrayrequest.txt');
         $gotLines = explode("\n", $this->_client->getLastRequest());
-        
+
         $this->assertEquals(count($expectedLines), count($gotLines));
-        
-        while (($expected = array_shift($expectedLines)) && 
+
+        while (($expected = array_shift($expectedLines)) &&
                ($got = array_shift($gotLines))) {
 
             $expected = trim($expected);
@@ -429,12 +429,12 @@ class Zend_Http_Client_StaticTest extends PHPUnit_Framework_TestCase
     }
 
     /**
-     * Data providers 
+     * Data providers
      */
-    
+
     /**
-     * Data provider of valid non-standard HTTP methods 
-     * 
+     * Data provider of valid non-standard HTTP methods
+     *
      * @return array
      */
     static public function validMethodProvider()
@@ -448,10 +448,10 @@ class Zend_Http_Client_StaticTest extends PHPUnit_Framework_TestCase
             array('X-MS-ENUMATTS')
         );
     }
-    
+
     /**
      * Data provider of invalid HTTP methods
-     * 
+     *
      * @return array
      */
     static public function invalidMethodProvider()

+ 53 - 53
tests/Zend/Http/Client/TestAdapterTest.php

@@ -16,31 +16,31 @@ require_once 'PHPUnit/Framework/TestCase.php';
  */
 class Zend_Http_Client_TestAdapterTest extends PHPUnit_Framework_TestCase
 {
-	/**
-	 * Test adapter
-	 * 
-	 * @var Zend_Http_Client_Adapter_Test
-	 */
-	protected $adapter;
-	
-	/**
-	 * Set up the test adapter before running the test
+    /**
+     * Test adapter
      *
-	 */
-	public function setUp()
-	{
+     * @var Zend_Http_Client_Adapter_Test
+     */
+    protected $adapter;
+
+    /**
+     * Set up the test adapter before running the test
+     *
+     */
+    public function setUp()
+    {
         $this->adapter = new Zend_Http_Client_Adapter_Test();
-	}
+    }
 
-	/**
-	 * Tear down the test adapter after running the test
+    /**
+     * Tear down the test adapter after running the test
      *
-	 */
-	public function tearDown()
-	{
-		$this->adapter = null;	
-	}
-	
+     */
+    public function tearDown()
+    {
+        $this->adapter = null;
+    }
+
     public function testSetConfigThrowsOnInvalidConfig()
     {
         try {
@@ -93,32 +93,32 @@ class Zend_Http_Client_TestAdapterTest extends PHPUnit_Framework_TestCase
         $this->assertEquals($expected[1], $this->adapter->read());
         $this->assertEquals($expected[0], $this->adapter->read());
     }
-    
+
     /**
      * Test that responses could be added as strings
-     * 
+     *
      * @dataProvider validHttpResponseProvider
      */
     public function testAddResponseAsString($testResponse)
     {
-    	$this->adapter->read(); // pop out first response
-    	
-    	$this->adapter->addResponse($testResponse);
-    	$this->assertEquals($testResponse, $this->adapter->read());
+        $this->adapter->read(); // pop out first response
+
+        $this->adapter->addResponse($testResponse);
+        $this->assertEquals($testResponse, $this->adapter->read());
     }
-    
+
     /**
      * Test that responses could be added as objects (ZF-7009)
-     * 
+     *
      * @link http://framework.zend.com/issues/browse/ZF-7009
      * @dataProvider validHttpResponseProvider
      */
     public function testAddResponseAsObject($testResponse)
     {
         $this->adapter->read(); // pop out first response
-        
+
         $respObj = Zend_Http_Response::fromString($testResponse);
-        
+
         $this->adapter->addResponse($respObj);
         $this->assertEquals($testResponse, $this->adapter->read());
     }
@@ -164,36 +164,36 @@ class Zend_Http_Client_TestAdapterTest extends PHPUnit_Framework_TestCase
             }
         }
     }
-    
+
     /**
      * Data Providers
      */
-    
+
     /**
      * Provide valid HTTP responses as string
-     * 
+     *
      * @return array
      */
     static public function validHttpResponseProvider()
     {
-    	return array(
-    	   array("HTTP/1.1 200 OK\r\n\r\n"),
-    	   array("HTTP/1.1 302 Moved Temporarily\r\nLocation: http://example.com/baz\r\n\r\n"),
-    	   array("HTTP/1.1 404 Not Found\r\n" . 
-    	         "Date: Sun, 14 Jun 2009 10:40:06 GMT\r\n" . 
-    	         "Server: Apache/2.2.3 (CentOS)\r\n" . 
-    	         "Content-length: 281\r\n" . 
-    	         "Connection: close\r\n" . 
-    	         "Content-type: text/html; charset=iso-8859-1\r\n\r\n" .
-    	         "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n" .
-    	         "<html><head>\n" . 
-    	         "<title>404 Not Found</title>\n" . 
-    	         "</head><body>\n" . 
-    	         "<h1>Not Found</h1>\n" . 
-    	         "<p>The requested URL /foo/bar was not found on this server.</p>\n" . 
-    	         "<hr>\n" . 
-    	         "<address>Apache/2.2.3 (CentOS) Server at example.com Port 80</address>\n" . 
-    	         "</body></html>") 
-    	);
+        return array(
+           array("HTTP/1.1 200 OK\r\n\r\n"),
+           array("HTTP/1.1 302 Moved Temporarily\r\nLocation: http://example.com/baz\r\n\r\n"),
+           array("HTTP/1.1 404 Not Found\r\n" .
+                 "Date: Sun, 14 Jun 2009 10:40:06 GMT\r\n" .
+                 "Server: Apache/2.2.3 (CentOS)\r\n" .
+                 "Content-length: 281\r\n" .
+                 "Connection: close\r\n" .
+                 "Content-type: text/html; charset=iso-8859-1\r\n\r\n" .
+                 "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n" .
+                 "<html><head>\n" .
+                 "<title>404 Not Found</title>\n" .
+                 "</head><body>\n" .
+                 "<h1>Not Found</h1>\n" .
+                 "<p>The requested URL /foo/bar was not found on this server.</p>\n" .
+                 "<hr>\n" .
+                 "<address>Apache/2.2.3 (CentOS) Server at example.com Port 80</address>\n" .
+                 "</body></html>")
+        );
     }
 }

+ 1 - 1
tests/Zend/Http/Client/_files/testHttpAuth.php

@@ -26,7 +26,7 @@ $gpass = isset($_GET['pass']) ? $_GET['pass'] : null;
 $method = isset($_GET['method']) ? $_GET['method'] : 'Basic';
 
 if (! $user || ! $pass || $user != $guser || $pass != $gpass) {
-	header('WWW-Authenticate: ' . $method . ' realm="ZendTest"');
+    header('WWW-Authenticate: ' . $method . ' realm="ZendTest"');
     header('HTTP/1.0 401 Unauthorized');
 }
 

+ 1 - 1
tests/Zend/Http/Client/_files/testPostData.php

@@ -1,2 +1,2 @@
 <?php
-	echo serialize($_POST);
+    echo serialize($_POST);

+ 4 - 4
tests/Zend/Http/Client/_files/testRedirections.php

@@ -5,9 +5,9 @@ $_GET['redirection']++;
 $https = isset($_SERVER['HTTPS']);
 
 if ($_GET['redirection'] < 4) {
-	$target = 'http' . ($https ? 's://' : '://')  . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
-	header('Location: ' . $target . '?redirection=' . $_GET['redirection']);
+    $target = 'http' . ($https ? 's://' : '://')  . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
+    header('Location: ' . $target . '?redirection=' . $_GET['redirection']);
 } else {
-	var_dump($_GET);
-	var_dump($_POST);
+    var_dump($_GET);
+    var_dump($_POST);
 }

+ 11 - 11
tests/Zend/Http/Client/_files/testRelativeRedirections.php

@@ -3,15 +3,15 @@
 if (! isset($_GET['redirect'])) $_GET['redirect'] = null;
 
 switch ($_GET['redirect']) {
-	case 'abpath':
-		header("Location: /path/to/fake/file.ext?redirect=abpath");
-		break;
-		
-	case 'relpath':
-		header("Location: path/to/fake/file.ext?redirect=relpath");
-		break;
-		
-	default:
-		echo "Redirections done.";
-		break;
+    case 'abpath':
+        header("Location: /path/to/fake/file.ext?redirect=abpath");
+        break;
+
+    case 'relpath':
+        header("Location: path/to/fake/file.ext?redirect=relpath");
+        break;
+
+    default:
+        echo "Redirections done.";
+        break;
 }

+ 7 - 7
tests/Zend/Http/Client/_files/testUploads.php

@@ -1,13 +1,13 @@
 <?php
 
 if (! empty($_FILES)) {
-	foreach ($_FILES as $name => $file) {
-	    if (is_array($file['name'])) {
-	        foreach($file['name'] as $k => $v) {
+    foreach ($_FILES as $name => $file) {
+        if (is_array($file['name'])) {
+            foreach($file['name'] as $k => $v) {
                 echo "$name $v {$file['type'][$k]} {$file['size'][$k]}\n";
             }
-	    } else {
-	        echo "$name {$file['name']} {$file['type']} {$file['size']}\n";
-	    }
-	}
+        } else {
+            echo "$name {$file['name']} {$file['type']} {$file['size']}\n";
+        }
+    }
 }

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

@@ -19,155 +19,155 @@ require_once 'Zend/Http/CookieJar.php';
 
 /**
  * Zend_Http_CookieJar unit tests
- * 
+ *
  * @category   Zend
  * @package    Zend_Http
  * @subpackage UnitTests
  * @copyright  Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com/)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
-class Zend_Http_CookieJarTest extends PHPUnit_Framework_TestCase 
+class Zend_Http_CookieJarTest extends PHPUnit_Framework_TestCase
 {
     /**
      * Test we can add cookies to the jar
-     * 
+     *
      */
-    public function testAddCookie() 
+    public function testAddCookie()
     {
         $jar = new Zend_Http_CookieJar();
         $this->assertEquals(0, count($jar->getAllCookies()), 'Cookie jar is expected to contain 0 cookies');
-        
+
         $jar->addCookie('foo=bar; domain=example.com');
         $cookie = $jar->getCookie('http://example.com/', 'foo');
         $this->assertTrue($cookie instanceof Zend_Http_Cookie, '$cookie is expected to be a Cookie object');
         $this->assertEquals('bar', $cookie->getValue(), 'Cookie value is expected to be "bar"');
-        
+
         $jar->addCookie('cookie=brownie; domain=geekz.co.uk;');
         $this->assertEquals(2, count($jar->getAllCookies()), 'Cookie jar is expected to contain 2 cookies');
     }
-    
+
     /**
      * Check we get an expection if a non-valid cookie is passed to addCookie
      *
      */
     public function testExceptAddInvalidCookie()
     {
-    	$jar = new Zend_Http_CookieJar();
-    	
-    	try {
-    		$jar->addCookie('garbage');
-    		$this->fail('Expected exception was not thrown');
-    	} catch (Zend_Http_Exception $e) {
-    		// We are ok
-    	}
-
-    	try {
-    		$jar->addCookie(new Zend_Http_Cookiejar());
-    		$this->fail('Expected exception was not thrown');
-    	} catch (Zend_Http_Exception $e) {
-    		// We are ok
-    	}
+        $jar = new Zend_Http_CookieJar();
+
+        try {
+            $jar->addCookie('garbage');
+            $this->fail('Expected exception was not thrown');
+        } catch (Zend_Http_Exception $e) {
+            // We are ok
+        }
+
+        try {
+            $jar->addCookie(new Zend_Http_Cookiejar());
+            $this->fail('Expected exception was not thrown');
+        } catch (Zend_Http_Exception $e) {
+            // We are ok
+        }
     }
 
     /**
      * Test we can read cookies from a Response object
      *
      */
-    public function testAddCookiesFromResponse() 
+    public function testAddCookiesFromResponse()
     {
-    	$jar = new Zend_Http_Cookiejar();
-    	$res_str = file_get_contents(dirname(realpath(__FILE__)) . 
-    	    DIRECTORY_SEPARATOR . '_files'  . DIRECTORY_SEPARATOR . 'response_with_cookies');
-    	$response = Zend_Http_Response::fromString($res_str);
-        
-    	$jar->addCookiesFromResponse($response, 'http://www.example.com');
-    	
-    	$this->assertEquals(3, count($jar->getAllCookies()));
-    	
-    	$cookie_str = 'foo=bar;BOFH=Feature+was+not+beta+tested;time=1164234700;';
-    	$this->assertEquals($cookie_str, $jar->getAllCookies(Zend_Http_CookieJar::COOKIE_STRING_CONCAT));
+        $jar = new Zend_Http_Cookiejar();
+        $res_str = file_get_contents(dirname(realpath(__FILE__)) .
+            DIRECTORY_SEPARATOR . '_files'  . DIRECTORY_SEPARATOR . 'response_with_cookies');
+        $response = Zend_Http_Response::fromString($res_str);
+
+        $jar->addCookiesFromResponse($response, 'http://www.example.com');
+
+        $this->assertEquals(3, count($jar->getAllCookies()));
+
+        $cookie_str = 'foo=bar;BOFH=Feature+was+not+beta+tested;time=1164234700;';
+        $this->assertEquals($cookie_str, $jar->getAllCookies(Zend_Http_CookieJar::COOKIE_STRING_CONCAT));
     }
-    
+
     public function testExceptAddCookiesInvalidResponse()
     {
-    	$jar = new Zend_Http_Cookiejar();
-    	
-    	try {
-    		$jar->addCookiesFromResponse('somestring', 'http://www.example.com');
-    		$this->fail('Excepted exception was not thrown');
-    	} catch (Zend_Http_Exception $e) {
-    		// We are ok
-    	}
-    	
-    	try {
-    		$jar->addCookiesFromResponse(new stdClass(), 'http://www.example.com');
-    		$this->fail('Excepted exception was not thrown');
-    	} catch (Zend_Http_Exception $e) {
-    		// We are ok
-    	}
+        $jar = new Zend_Http_Cookiejar();
+
+        try {
+            $jar->addCookiesFromResponse('somestring', 'http://www.example.com');
+            $this->fail('Excepted exception was not thrown');
+        } catch (Zend_Http_Exception $e) {
+            // We are ok
+        }
+
+        try {
+            $jar->addCookiesFromResponse(new stdClass(), 'http://www.example.com');
+            $this->fail('Excepted exception was not thrown');
+        } catch (Zend_Http_Exception $e) {
+            // We are ok
+        }
     }
 
     /**
      * Test we can get all cookies as an array of Cookie objects
-     * 
+     *
      */
-    public function testGetAllCookies() 
+    public function testGetAllCookies()
     {
         $jar = new Zend_Http_CookieJar();
-        
+
         $cookies = array(
             'name=Arthur; domain=camelot.gov.uk',
             'quest=holy+grail; domain=forest.euwing.com',
             'swallow=african; domain=bridge-of-death.net'
         );
-        
+
         foreach ($cookies as $cookie) {
-        	$jar->addCookie($cookie);
+            $jar->addCookie($cookie);
         }
-        
+
         $cobjects = $jar->getAllCookies();
-        
+
         foreach ($cobjects as $id => $cookie) {
-        	$this->assertContains($cookie->__toString(), $cookies[$id]);
+            $this->assertContains($cookie->__toString(), $cookies[$id]);
         }
     }
-    
+
     /**
      * Test we can get all cookies as a concatenated string
-     * 
+     *
      */
-    public function testGetAllCookiesAsConcat() 
+    public function testGetAllCookiesAsConcat()
     {
         $jar = new Zend_Http_CookieJar();
-        
+
         $cookies = array(
             'name=Arthur; domain=camelot.gov.uk',
             'quest=holy+grail; domain=forest.euwing.com',
             'swallow=african; domain=bridge-of-death.net'
         );
-        
+
         foreach ($cookies as $cookie) {
-        	$jar->addCookie($cookie);
+            $jar->addCookie($cookie);
         }
-        
+
         $expected = 'name=Arthur;quest=holy+grail;swallow=african;';
         $real = $jar->getAllCookies(Zend_Http_CookieJar::COOKIE_STRING_CONCAT );
-        
+
         $this->assertEquals($expected, $real, 'Concatenated string is not as expected');
     }
 
     /**
      * Test we can get a single cookie as an object
-     * 
+     *
      */
-    public function testGetCookieAsObject() 
+    public function testGetCookieAsObject()
     {
         $cookie = Zend_Http_Cookie::fromString('foo=bar; domain=www.example.com; path=/tests');
         $jar = new Zend_Http_CookieJar();
         $jar->addCookie($cookie->__toString(), 'http://www.example.com/tests/');
-        
+
         $cobj = $jar->getCookie('http://www.example.com/tests/', 'foo');
-        
+
         $this->assertTrue($cobj instanceof Zend_Http_Cookie, '$cobj is not a Cookie object');
         $this->assertEquals($cookie->getName(), $cobj->getName(), 'Cookie name is not as expected');
         $this->assertEquals($cookie->getValue(), $cobj->getValue(), 'Cookie value is not as expected');
@@ -178,12 +178,12 @@ class Zend_Http_CookieJarTest extends PHPUnit_Framework_TestCase
     /**
      * Check we can get a cookie as a string
      */
-    public function testGetCookieAsString() 
+    public function testGetCookieAsString()
     {
         $cookie = Zend_Http_Cookie::fromString('foo=bar; domain=www.example.com; path=/tests');
         $jar = new Zend_Http_CookieJar();
         $jar->addCookie($cookie);
-        
+
         $cstr = $jar->getCookie('http://www.example.com/tests/', 'foo', Zend_Http_CookieJar::COOKIE_STRING_ARRAY);
         $this->assertEquals($cookie->__toString(), $cstr, 'Cookie string is not the expected string');
 
@@ -199,13 +199,13 @@ class Zend_Http_CookieJarTest extends PHPUnit_Framework_TestCase
         $cookie = Zend_Http_Cookie::fromString('foo=bar; domain=www.example.com; path=/tests');
         $jar = new Zend_Http_CookieJar();
         $jar->addCookie($cookie);
-        
+
         $cstr = $jar->getCookie('http://www.example.com/tests/', 'otherfoo', Zend_Http_CookieJar::COOKIE_STRING_ARRAY);
         $this->assertFalse($cstr, 'getCookie was expected to return false, no such cookie');
 
         $cstr = $jar->getCookie('http://www.otherexample.com/tests/', 'foo', Zend_Http_CookieJar::COOKIE_STRING_CONCAT);
         $this->assertFalse($cstr, 'getCookie was expected to return false, no such domain');
-        
+
         $cstr = $jar->getCookie('http://www.example.com/othertests/', 'foo', Zend_Http_CookieJar::COOKIE_STRING_CONCAT);
         $this->assertFalse($cstr, 'getCookie was expected to return false, no such path');
     }
@@ -213,43 +213,43 @@ class Zend_Http_CookieJarTest extends PHPUnit_Framework_TestCase
     /**
      * Test we get a proper exception when an invalid URI is passed
      */
-    public function testExceptGetCookieInvalidUri() 
+    public function testExceptGetCookieInvalidUri()
     {
-    	$cookie = Zend_Http_Cookie::fromString('foo=bar; domain=www.example.com; path=/tests');
+        $cookie = Zend_Http_Cookie::fromString('foo=bar; domain=www.example.com; path=/tests');
         $jar = new Zend_Http_CookieJar();
         $jar->addCookie($cookie);
-        
-    	try {
-    		$jar->getCookie('foo.com', 'foo');
-    		$this->fail('Expected getCookie to throw exception, invalid URI string passed');
-    	} catch (Zend_Exception $e) {
-    		// We are ok!
-    	}
-    	
-    	try {
-    		$jar->getCookie(Zend_Uri::factory('mailto:nobody@dev.null.com'), 'foo');
-    		$this->fail('Expected getCookie to throw exception, invalid URI object passed');
-    	} catch (Zend_Exception $e) {
-    		// We are ok!
-    	}
+
+        try {
+            $jar->getCookie('foo.com', 'foo');
+            $this->fail('Expected getCookie to throw exception, invalid URI string passed');
+        } catch (Zend_Exception $e) {
+            // We are ok!
+        }
+
+        try {
+            $jar->getCookie(Zend_Uri::factory('mailto:nobody@dev.null.com'), 'foo');
+            $this->fail('Expected getCookie to throw exception, invalid URI object passed');
+        } catch (Zend_Exception $e) {
+            // We are ok!
+        }
     }
 
     /**
      * Test we get a proper exception when an invalid return constant is passed
-     * 
+     *
      */
-    public function testExceptGetCookieInvalidReturnType() 
+    public function testExceptGetCookieInvalidReturnType()
     {
         $cookie = Zend_Http_Cookie::fromString('foo=bar; domain=example.com;');
         $jar = new Zend_Http_CookieJar();
         $jar->addCookie($cookie);
-        
-    	try {
-    		$jar->getCookie('http://example.com/', 'foo', 5);
-    		$this->fail('Expected getCookie to throw exception, invalid return type');
-    	} catch (Zend_Http_Exception $e) {
-    		// We are ok!
-    	}
+
+        try {
+            $jar->getCookie('http://example.com/', 'foo', 5);
+            $this->fail('Expected getCookie to throw exception, invalid return type');
+        } catch (Zend_Http_Exception $e) {
+            // We are ok!
+        }
     }
 
     /**
@@ -258,26 +258,26 @@ class Zend_Http_CookieJarTest extends PHPUnit_Framework_TestCase
     public function testGetMatchingCookies()
     {
         $jar = new Zend_Http_CookieJar();
-    	$cookies = array(
-    		Zend_Http_Cookie::fromString('foo1=bar1; domain=.foo.com; path=/path; expires=' . date(DATE_COOKIE, time() + 3600)),
-    		Zend_Http_Cookie::fromString('foo2=bar2; domain=.foo.com; path=/; expires=' . date(DATE_COOKIE, time() + 3600)),
-    		Zend_Http_Cookie::fromString('foo3=bar3; domain=.foo.com; path=/; expires=' . date(DATE_COOKIE, time() - 3600)),
-    		Zend_Http_Cookie::fromString('foo4=bar4; domain=.foo.com; path=/;'),
-    		Zend_Http_Cookie::fromString('foo5=bar5; domain=.foo.com; path=/; secure; expires=' . date(DATE_COOKIE, time() + 3600)),
-    		Zend_Http_Cookie::fromString('foo6=bar6; domain=.foo.com; path=/otherpath; expires=' . date(DATE_COOKIE, time() + 3600)),
-    		Zend_Http_Cookie::fromString('foo7=bar7; domain=www.foo.com; path=/path; expires=' . date(DATE_COOKIE, time() + 3600)),
-    		Zend_Http_Cookie::fromString('foo8=bar8; domain=subdomain.foo.com; path=/path; expires=' . date(DATE_COOKIE, time() + 3600)),
-    	);
-    	
-    	foreach ($cookies as $cookie) $jar->addCookie($cookie);
-    	
-    	$this->assertEquals(8, count($jar->getAllCookies()), 'Cookie count is expected to be 8');
-    	
-    	$cookies = $jar->getMatchingCookies('http://www.foo.com/path/file.txt');
-    	$this->assertEquals(4, count($cookies), 'Cookie count is expected to be 4');
-
-    	$cookies = $jar->getMatchingCookies('https://www.foo.com/path/file.txt');
-    	$this->assertEquals(5, count($cookies), 'Cookie count is expected to be 5');
+        $cookies = array(
+            Zend_Http_Cookie::fromString('foo1=bar1; domain=.foo.com; path=/path; expires=' . date(DATE_COOKIE, time() + 3600)),
+            Zend_Http_Cookie::fromString('foo2=bar2; domain=.foo.com; path=/; expires=' . date(DATE_COOKIE, time() + 3600)),
+            Zend_Http_Cookie::fromString('foo3=bar3; domain=.foo.com; path=/; expires=' . date(DATE_COOKIE, time() - 3600)),
+            Zend_Http_Cookie::fromString('foo4=bar4; domain=.foo.com; path=/;'),
+            Zend_Http_Cookie::fromString('foo5=bar5; domain=.foo.com; path=/; secure; expires=' . date(DATE_COOKIE, time() + 3600)),
+            Zend_Http_Cookie::fromString('foo6=bar6; domain=.foo.com; path=/otherpath; expires=' . date(DATE_COOKIE, time() + 3600)),
+            Zend_Http_Cookie::fromString('foo7=bar7; domain=www.foo.com; path=/path; expires=' . date(DATE_COOKIE, time() + 3600)),
+            Zend_Http_Cookie::fromString('foo8=bar8; domain=subdomain.foo.com; path=/path; expires=' . date(DATE_COOKIE, time() + 3600)),
+        );
+
+        foreach ($cookies as $cookie) $jar->addCookie($cookie);
+
+        $this->assertEquals(8, count($jar->getAllCookies()), 'Cookie count is expected to be 8');
+
+        $cookies = $jar->getMatchingCookies('http://www.foo.com/path/file.txt');
+        $this->assertEquals(4, count($cookies), 'Cookie count is expected to be 4');
+
+        $cookies = $jar->getMatchingCookies('https://www.foo.com/path/file.txt');
+        $this->assertEquals(5, count($cookies), 'Cookie count is expected to be 5');
     }
 
     /**
@@ -286,153 +286,153 @@ class Zend_Http_CookieJarTest extends PHPUnit_Framework_TestCase
     public function testGetMatchingCookiesNoSession()
     {
         $jar = new Zend_Http_CookieJar();
-    	$cookies = array(
-    		Zend_Http_Cookie::fromString('foo1=bar1; domain=.foo.com; path=/path; expires=' . date(DATE_COOKIE, time() + 3600)),
-    		Zend_Http_Cookie::fromString('foo2=bar2; domain=.foo.com; path=/; expires=' . date(DATE_COOKIE, time() + 3600)),
-    		Zend_Http_Cookie::fromString('foo3=bar3; domain=.foo.com; path=/; expires=' . date(DATE_COOKIE, time() - 3600)),
-    		Zend_Http_Cookie::fromString('foo4=bar4; domain=.foo.com; path=/;'),
-    		Zend_Http_Cookie::fromString('foo5=bar5; domain=.foo.com; path=/; secure; expires=' . date(DATE_COOKIE, time() + 3600)),
-    		Zend_Http_Cookie::fromString('foo6=bar6; domain=.foo.com; path=/otherpath; expires=' . date(DATE_COOKIE, time() + 3600)),
-    		Zend_Http_Cookie::fromString('foo7=bar7; domain=www.foo.com; path=/path; expires=' . date(DATE_COOKIE, time() + 3600)),
-    		Zend_Http_Cookie::fromString('foo8=bar8; domain=subdomain.foo.com; path=/path; expires=' . date(DATE_COOKIE, time() + 3600)),
-    	);
-    	
-    	foreach ($cookies as $cookie) $jar->addCookie($cookie);
-    	
-    	$this->assertEquals(8, count($jar->getAllCookies()), 'Cookie count is expected to be 8');
-    	
-    	$cookies = $jar->getMatchingCookies('http://www.foo.com/path/file.txt', false);
-    	$this->assertEquals(3, count($cookies), 'Cookie count is expected to be 3');
-
-    	$cookies = $jar->getMatchingCookies('https://www.foo.com/path/file.txt', false);
-    	$this->assertEquals(4, count($cookies), 'Cookie count is expected to be 4');
+        $cookies = array(
+            Zend_Http_Cookie::fromString('foo1=bar1; domain=.foo.com; path=/path; expires=' . date(DATE_COOKIE, time() + 3600)),
+            Zend_Http_Cookie::fromString('foo2=bar2; domain=.foo.com; path=/; expires=' . date(DATE_COOKIE, time() + 3600)),
+            Zend_Http_Cookie::fromString('foo3=bar3; domain=.foo.com; path=/; expires=' . date(DATE_COOKIE, time() - 3600)),
+            Zend_Http_Cookie::fromString('foo4=bar4; domain=.foo.com; path=/;'),
+            Zend_Http_Cookie::fromString('foo5=bar5; domain=.foo.com; path=/; secure; expires=' . date(DATE_COOKIE, time() + 3600)),
+            Zend_Http_Cookie::fromString('foo6=bar6; domain=.foo.com; path=/otherpath; expires=' . date(DATE_COOKIE, time() + 3600)),
+            Zend_Http_Cookie::fromString('foo7=bar7; domain=www.foo.com; path=/path; expires=' . date(DATE_COOKIE, time() + 3600)),
+            Zend_Http_Cookie::fromString('foo8=bar8; domain=subdomain.foo.com; path=/path; expires=' . date(DATE_COOKIE, time() + 3600)),
+        );
+
+        foreach ($cookies as $cookie) $jar->addCookie($cookie);
+
+        $this->assertEquals(8, count($jar->getAllCookies()), 'Cookie count is expected to be 8');
+
+        $cookies = $jar->getMatchingCookies('http://www.foo.com/path/file.txt', false);
+        $this->assertEquals(3, count($cookies), 'Cookie count is expected to be 3');
+
+        $cookies = $jar->getMatchingCookies('https://www.foo.com/path/file.txt', false);
+        $this->assertEquals(4, count($cookies), 'Cookie count is expected to be 4');
     }
-    
+
     /**
      * Test we can get all matching cookies for a request, when we set a different time for now
      */
     public function testGetMatchingCookiesWithTime()
     {
         $jar = new Zend_Http_CookieJar();
-    	$cookies = array(
-    		Zend_Http_Cookie::fromString('foo1=bar1; domain=.foo.com; path=/path; expires=' . date(DATE_COOKIE, time() + 3600)),
-    		Zend_Http_Cookie::fromString('foo2=bar2; domain=.foo.com; path=/; expires=' . date(DATE_COOKIE, time() + 7200)),
-    		Zend_Http_Cookie::fromString('foo3=bar3; domain=.foo.com; path=/; expires=' . date(DATE_COOKIE, time() - 3600)),
-    		Zend_Http_Cookie::fromString('foo4=bar4; domain=.foo.com; path=/;'),
-    		Zend_Http_Cookie::fromString('foo5=bar5; domain=.foo.com; path=/; secure; expires=' . date(DATE_COOKIE, time() - 7200)),
-    		Zend_Http_Cookie::fromString('foo6=bar6; domain=.foo.com; path=/otherpath; expires=' . date(DATE_COOKIE, time() + 3600)),
-    		Zend_Http_Cookie::fromString('foo7=bar7; domain=www.foo.com; path=/path; expires=' . date(DATE_COOKIE, time() + 3600)),
-    		Zend_Http_Cookie::fromString('foo8=bar8; domain=subdomain.foo.com; path=/path; expires=' . date(DATE_COOKIE, time() + 3600)),
-    	);
-    	
-    	foreach ($cookies as $cookie) $jar->addCookie($cookie);
-    	
-    	$this->assertEquals(8, count($jar->getAllCookies()), 'Cookie count is expected to be 8');
-    	
-    	$cookies = $jar->getMatchingCookies('http://www.foo.com/path/file.txt', true, Zend_Http_CookieJar::COOKIE_OBJECT, time() + 3700);
-    	$this->assertEquals(2, count($cookies), 'Cookie count is expected to be 2');
-
-    	$cookies = $jar->getMatchingCookies('http://www.foo.com/path/file.txt', true, Zend_Http_CookieJar::COOKIE_OBJECT, time() - 3700);
-    	$this->assertEquals(5, count($cookies), 'Cookie count is expected to be 5');
+        $cookies = array(
+            Zend_Http_Cookie::fromString('foo1=bar1; domain=.foo.com; path=/path; expires=' . date(DATE_COOKIE, time() + 3600)),
+            Zend_Http_Cookie::fromString('foo2=bar2; domain=.foo.com; path=/; expires=' . date(DATE_COOKIE, time() + 7200)),
+            Zend_Http_Cookie::fromString('foo3=bar3; domain=.foo.com; path=/; expires=' . date(DATE_COOKIE, time() - 3600)),
+            Zend_Http_Cookie::fromString('foo4=bar4; domain=.foo.com; path=/;'),
+            Zend_Http_Cookie::fromString('foo5=bar5; domain=.foo.com; path=/; secure; expires=' . date(DATE_COOKIE, time() - 7200)),
+            Zend_Http_Cookie::fromString('foo6=bar6; domain=.foo.com; path=/otherpath; expires=' . date(DATE_COOKIE, time() + 3600)),
+            Zend_Http_Cookie::fromString('foo7=bar7; domain=www.foo.com; path=/path; expires=' . date(DATE_COOKIE, time() + 3600)),
+            Zend_Http_Cookie::fromString('foo8=bar8; domain=subdomain.foo.com; path=/path; expires=' . date(DATE_COOKIE, time() + 3600)),
+        );
+
+        foreach ($cookies as $cookie) $jar->addCookie($cookie);
+
+        $this->assertEquals(8, count($jar->getAllCookies()), 'Cookie count is expected to be 8');
+
+        $cookies = $jar->getMatchingCookies('http://www.foo.com/path/file.txt', true, Zend_Http_CookieJar::COOKIE_OBJECT, time() + 3700);
+        $this->assertEquals(2, count($cookies), 'Cookie count is expected to be 2');
+
+        $cookies = $jar->getMatchingCookies('http://www.foo.com/path/file.txt', true, Zend_Http_CookieJar::COOKIE_OBJECT, time() - 3700);
+        $this->assertEquals(5, count($cookies), 'Cookie count is expected to be 5');
     }
-    
+
     /**
      * Test we can get all matching cookies for a request, and return as strings array / concat
      */
     public function testGetMatchingCookiesAsStrings()
     {
         $jar = new Zend_Http_CookieJar();
-    	$cookies = array(
-    		Zend_Http_Cookie::fromString('foo1=bar1; domain=.foo.com; path=/path; expires=' . date(DATE_COOKIE, time() + 3600)),
-    		Zend_Http_Cookie::fromString('foo2=bar2; domain=.foo.com; path=/; expires=' . date(DATE_COOKIE, time() + 3600)),
-    		Zend_Http_Cookie::fromString('foo3=bar3; domain=.foo.com; path=/; expires=' . date(DATE_COOKIE, time() - 3600)),
-    		Zend_Http_Cookie::fromString('foo4=bar4; domain=.foo.com; path=/;'),
-    		Zend_Http_Cookie::fromString('foo5=bar5; domain=.foo.com; path=/; secure; expires=' . date(DATE_COOKIE, time() + 3600)),
-    		Zend_Http_Cookie::fromString('foo6=bar6; domain=.foo.com; path=/otherpath; expires=' . date(DATE_COOKIE, time() + 3600)),
-    		Zend_Http_Cookie::fromString('foo7=bar7; domain=www.foo.com; path=/path; expires=' . date(DATE_COOKIE, time() + 3600)),
-    		Zend_Http_Cookie::fromString('foo8=bar8; domain=subdomain.foo.com; path=/path; expires=' . date(DATE_COOKIE, time() + 3600)),
-    	);
-    	
-    	foreach ($cookies as $cookie) $jar->addCookie($cookie);
-    	
-    	$this->assertEquals(8, count($jar->getAllCookies()), 'Cookie count is expected to be 8');
-    	
-    	$cookies = $jar->getMatchingCookies('http://www.foo.com/path/file.txt', true, Zend_Http_CookieJar::COOKIE_STRING_ARRAY);
-    	$this->assertType('array', $cookies, '$cookies is expected to be an array, but it is not');
-    	$this->assertType('string', $cookies[0], '$cookies[0] is expected to be a string');;
-
-    	$cookies = $jar->getMatchingCookies('http://www.foo.com/path/file.txt', true, Zend_Http_CookieJar::COOKIE_STRING_CONCAT);
-    	$this->assertType('string', $cookies, '$cookies is expected to be a string');
+        $cookies = array(
+            Zend_Http_Cookie::fromString('foo1=bar1; domain=.foo.com; path=/path; expires=' . date(DATE_COOKIE, time() + 3600)),
+            Zend_Http_Cookie::fromString('foo2=bar2; domain=.foo.com; path=/; expires=' . date(DATE_COOKIE, time() + 3600)),
+            Zend_Http_Cookie::fromString('foo3=bar3; domain=.foo.com; path=/; expires=' . date(DATE_COOKIE, time() - 3600)),
+            Zend_Http_Cookie::fromString('foo4=bar4; domain=.foo.com; path=/;'),
+            Zend_Http_Cookie::fromString('foo5=bar5; domain=.foo.com; path=/; secure; expires=' . date(DATE_COOKIE, time() + 3600)),
+            Zend_Http_Cookie::fromString('foo6=bar6; domain=.foo.com; path=/otherpath; expires=' . date(DATE_COOKIE, time() + 3600)),
+            Zend_Http_Cookie::fromString('foo7=bar7; domain=www.foo.com; path=/path; expires=' . date(DATE_COOKIE, time() + 3600)),
+            Zend_Http_Cookie::fromString('foo8=bar8; domain=subdomain.foo.com; path=/path; expires=' . date(DATE_COOKIE, time() + 3600)),
+        );
+
+        foreach ($cookies as $cookie) $jar->addCookie($cookie);
+
+        $this->assertEquals(8, count($jar->getAllCookies()), 'Cookie count is expected to be 8');
+
+        $cookies = $jar->getMatchingCookies('http://www.foo.com/path/file.txt', true, Zend_Http_CookieJar::COOKIE_STRING_ARRAY);
+        $this->assertType('array', $cookies, '$cookies is expected to be an array, but it is not');
+        $this->assertType('string', $cookies[0], '$cookies[0] is expected to be a string');;
+
+        $cookies = $jar->getMatchingCookies('http://www.foo.com/path/file.txt', true, Zend_Http_CookieJar::COOKIE_STRING_CONCAT);
+        $this->assertType('string', $cookies, '$cookies is expected to be a string');
     }
-    
-	/**
+
+    /**
      * Test we get a proper exception when an invalid URI is passed
      */
-    public function testExceptGetMatchingCookiesInvalidUri() 
+    public function testExceptGetMatchingCookiesInvalidUri()
     {
         $jar = new Zend_Http_CookieJar();
-    	        
-    	try {
-    	    $cookies = $jar->getMatchingCookies('invalid.com', true, Zend_Http_CookieJar::COOKIE_STRING_ARRAY);
-    		$this->fail('Expected getMatchingCookies to throw exception, invalid URI string passed');
-    	} catch (Zend_Exception $e) {
-    		// We are ok!
-    	}
-    	
-    	try {
-    		$cookies = $jar->getMatchingCookies(new stdClass(), true, Zend_Http_CookieJar::COOKIE_STRING_ARRAY);
-    		$this->fail('Expected getCookie to throw exception, invalid URI object passed');
-    	} catch (Zend_Exception $e) {
-    		// We are ok!
-    	}
+
+        try {
+            $cookies = $jar->getMatchingCookies('invalid.com', true, Zend_Http_CookieJar::COOKIE_STRING_ARRAY);
+            $this->fail('Expected getMatchingCookies to throw exception, invalid URI string passed');
+        } catch (Zend_Exception $e) {
+            // We are ok!
+        }
+
+        try {
+            $cookies = $jar->getMatchingCookies(new stdClass(), true, Zend_Http_CookieJar::COOKIE_STRING_ARRAY);
+            $this->fail('Expected getCookie to throw exception, invalid URI object passed');
+        } catch (Zend_Exception $e) {
+            // We are ok!
+        }
     }
-    
+
     /**
      * Test we can build a new object from a response object (single cookie header)
      */
-    public function testFromResponse() 
+    public function testFromResponse()
     {
-    	$res_str = file_get_contents(dirname(realpath(__FILE__)) . 
-    	    DIRECTORY_SEPARATOR . '_files'  . DIRECTORY_SEPARATOR . 'response_with_single_cookie');
-    	$response = Zend_Http_Response::fromString($res_str);
-        
-    	$jar = Zend_Http_CookieJar::fromResponse($response, 'http://www.example.com');
-    	
-    	$this->assertTrue($jar instanceof Zend_Http_CookieJar, '$jar is not an instance of CookieJar as expected');
-    	$this->assertEquals(1, count($jar->getAllCookies()), 'CookieJar expected to contain 1 cookie');
+        $res_str = file_get_contents(dirname(realpath(__FILE__)) .
+            DIRECTORY_SEPARATOR . '_files'  . DIRECTORY_SEPARATOR . 'response_with_single_cookie');
+        $response = Zend_Http_Response::fromString($res_str);
+
+        $jar = Zend_Http_CookieJar::fromResponse($response, 'http://www.example.com');
+
+        $this->assertTrue($jar instanceof Zend_Http_CookieJar, '$jar is not an instance of CookieJar as expected');
+        $this->assertEquals(1, count($jar->getAllCookies()), 'CookieJar expected to contain 1 cookie');
     }
-    
+
     /**
      * Test we can build a new object from a response object (multiple cookie headers)
      */
-    public function testFromResponseMultiHeader() 
+    public function testFromResponseMultiHeader()
     {
-    	$res_str = file_get_contents(dirname(realpath(__FILE__)) . 
-    	    DIRECTORY_SEPARATOR . '_files'  . DIRECTORY_SEPARATOR . 'response_with_cookies');
-    	$response = Zend_Http_Response::fromString($res_str);
-        
-    	$jar = Zend_Http_CookieJar::fromResponse($response, 'http://www.example.com');
-    	
-    	$this->assertTrue($jar instanceof Zend_Http_CookieJar, '$jar is not an instance of CookieJar as expected');
-    	$this->assertEquals(3, count($jar->getAllCookies()), 'CookieJar expected to contain 3 cookies');
+        $res_str = file_get_contents(dirname(realpath(__FILE__)) .
+            DIRECTORY_SEPARATOR . '_files'  . DIRECTORY_SEPARATOR . 'response_with_cookies');
+        $response = Zend_Http_Response::fromString($res_str);
+
+        $jar = Zend_Http_CookieJar::fromResponse($response, 'http://www.example.com');
+
+        $this->assertTrue($jar instanceof Zend_Http_CookieJar, '$jar is not an instance of CookieJar as expected');
+        $this->assertEquals(3, count($jar->getAllCookies()), 'CookieJar expected to contain 3 cookies');
     }
-    
+
     /**
      * Make sure that paths with trailing slashes are matched as well as paths with no trailing slashes
      */
     public function testMatchPathWithTrailingSlash()
     {
-    	$jar = new Zend_Http_CookieJar();
-    	$cookies = array(
-    		Zend_Http_Cookie::fromString('foo1=bar1; domain=.example.com; path=/a/b'),
-    		Zend_Http_Cookie::fromString('foo2=bar2; domain=.example.com; path=/a/b/')
-    	);
-    	
-    	foreach ($cookies as $cookie) $jar->addCookie($cookie);
-    	$cookies = $jar->getMatchingCookies('http://www.example.com/a/b/file.txt');
-    	
-    	$this->assertType('array', $cookies);
-    	$this->assertEquals(2, count($cookies));    	
+        $jar = new Zend_Http_CookieJar();
+        $cookies = array(
+            Zend_Http_Cookie::fromString('foo1=bar1; domain=.example.com; path=/a/b'),
+            Zend_Http_Cookie::fromString('foo2=bar2; domain=.example.com; path=/a/b/')
+        );
+
+        foreach ($cookies as $cookie) $jar->addCookie($cookie);
+        $cookies = $jar->getMatchingCookies('http://www.example.com/a/b/file.txt');
+
+        $this->assertType('array', $cookies);
+        $this->assertEquals(2, count($cookies));
     }
 
     public function testIteratorAndCountable()

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

@@ -14,185 +14,185 @@ require_once 'Zend/Http/Cookie.php';
 
 /**
  * Zend_Http_Cookie unit tests
- * 
+ *
  * @category   Zend
  * @package    Zend_Http
  * @subpackage UnitTests
  * @copyright  Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com/)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
-class Zend_Http_CookieTest extends PHPUnit_Framework_TestCase 
+class Zend_Http_CookieTest extends PHPUnit_Framework_TestCase
 {
-	/**
-	 * Make sure we can't set invalid names
-	 */
+    /**
+     * Make sure we can't set invalid names
+     */
     public function testSetInvalidName()
     {
-    	$invalidcharacters = "=,; \t\r\n\013\014";
-    	$l = strlen($invalidcharacters) - 1;
-    	for ($i = 0; $i < $l; $i++) {
-    		$name = 'cookie_' . $invalidcharacters[$i];
-    		try {
-    			$cookie = new Zend_Http_Cookie($name, 'foo', 'example.com');
-    			$this->fail('Expected invalid cookie name exception was not thrown for "' . $name . '"');
-    		} catch (Zend_Http_Exception $e) {
-    			// We're good!
-    		}
-    	}
+        $invalidcharacters = "=,; \t\r\n\013\014";
+        $l = strlen($invalidcharacters) - 1;
+        for ($i = 0; $i < $l; $i++) {
+            $name = 'cookie_' . $invalidcharacters[$i];
+            try {
+                $cookie = new Zend_Http_Cookie($name, 'foo', 'example.com');
+                $this->fail('Expected invalid cookie name exception was not thrown for "' . $name . '"');
+            } catch (Zend_Http_Exception $e) {
+                // We're good!
+            }
+        }
     }
-    
-	/**
+
+    /**
      * Test we get the cookie name properly
      */
-    public function testGetName() 
+    public function testGetName()
     {
-    	// Array of cookies and their names. We need to test each 'keyword' in
-    	// a cookie string
-    	$cookies = array(
-    		'justacookie' => 'justacookie=foo; domain=example.com',
-    		'expires'     => 'expires=tomorrow; expires=Tue, 21-Nov-2006 08:33:44 GMT; domain=example.com',
-    		'domain'      => 'domain=unittests; expires=Tue, 21-Nov-2006 08:33:44 GMT; domain=example.com', 
-    		'path'        => 'path=indexAction; path=/; domain=.foo.com',
-    		'secure'      => 'secure=sha1; secure; domain=.foo.com',
-    		'PHPSESSID'   => 'PHPSESSID=1234567890abcdef; secure; domain=.foo.com; path=/; expires=Tue, 21-Nov-2006 08:33:44 GMT;'
-    	);
-    	
-    	foreach ($cookies as $name => $cstr) {
-    		$cookie = Zend_Http_Cookie::fromString($cstr);
-    		if (! $cookie instanceof Zend_Http_Cookie) $this->fail('Cookie ' . $name . ' is not a proper Cookie object');
-    		$this->assertEquals($name, $cookie->getName(), 'Cookie name is not as expected');
-    	}
+        // Array of cookies and their names. We need to test each 'keyword' in
+        // a cookie string
+        $cookies = array(
+            'justacookie' => 'justacookie=foo; domain=example.com',
+            'expires'     => 'expires=tomorrow; expires=Tue, 21-Nov-2006 08:33:44 GMT; domain=example.com',
+            'domain'      => 'domain=unittests; expires=Tue, 21-Nov-2006 08:33:44 GMT; domain=example.com',
+            'path'        => 'path=indexAction; path=/; domain=.foo.com',
+            'secure'      => 'secure=sha1; secure; domain=.foo.com',
+            'PHPSESSID'   => 'PHPSESSID=1234567890abcdef; secure; domain=.foo.com; path=/; expires=Tue, 21-Nov-2006 08:33:44 GMT;'
+        );
+
+        foreach ($cookies as $name => $cstr) {
+            $cookie = Zend_Http_Cookie::fromString($cstr);
+            if (! $cookie instanceof Zend_Http_Cookie) $this->fail('Cookie ' . $name . ' is not a proper Cookie object');
+            $this->assertEquals($name, $cookie->getName(), 'Cookie name is not as expected');
+        }
     }
 
     /**
      * Make sure we get the correct value if it was set through the constructor
-     * 
+     *
      */
-    public function testGetValueConstructor() 
+    public function testGetValueConstructor()
     {
-    	$values = array(
-    		'simpleCookie', 'space cookie', '!@#$%^*&()* ][{}?;', "line\n\rbreaks"
-    	);
-    	
-    	foreach ($values as $val) {
-    		$cookie = new Zend_Http_Cookie('cookie', $val, 'example.com', time(), '/', true);
-    		$this->assertEquals($val, $cookie->getValue());
-    	}
+        $values = array(
+            'simpleCookie', 'space cookie', '!@#$%^*&()* ][{}?;', "line\n\rbreaks"
+        );
+
+        foreach ($values as $val) {
+            $cookie = new Zend_Http_Cookie('cookie', $val, 'example.com', time(), '/', true);
+            $this->assertEquals($val, $cookie->getValue());
+        }
     }
-    
+
     /**
      * Make sure we get the correct value if it was set through fromString()
      *
      */
     public function testGetValueFromString()
     {
-    	$values = array(
-    		'simpleCookie', 'space cookie', '!@#$%^*&()* ][{}?;', "line\n\rbreaks"
-    	);
-    	
-    	foreach ($values as $val) {
-    		$cookie = Zend_Http_Cookie::fromString('cookie=' . urlencode($val) . '; domain=example.com');
-    		$this->assertEquals($val, $cookie->getValue());
-    	}
+        $values = array(
+            'simpleCookie', 'space cookie', '!@#$%^*&()* ][{}?;', "line\n\rbreaks"
+        );
+
+        foreach ($values as $val) {
+            $cookie = Zend_Http_Cookie::fromString('cookie=' . urlencode($val) . '; domain=example.com');
+            $this->assertEquals($val, $cookie->getValue());
+        }
     }
 
     /**
      * Make sure we get the correct domain when it's set in the cookie string
-     * 
+     *
      */
-    public function testGetDomainInStr() 
+    public function testGetDomainInStr()
     {
         $domains = array(
             'cookie=foo; domain=example.com' => 'example.com',
             'cookie=foo; path=/; expires=Tue, 21-Nov-2006 08:33:44 GMT; domain=.example.com;' => '.example.com',
             'cookie=foo; domain=some.really.deep.domain.com; path=/; expires=Tue, 21-Nov-2006 08:33:44 GMT;' => 'some.really.deep.domain.com'
         );
-    	
+
         foreach ($domains as $cstr => $domain) {
-        	$cookie = Zend_Http_Cookie::fromString($cstr);
-        	if (! $cookie instanceof Zend_Http_Cookie) $this->fail('We didn\'t get a valid Cookie object');
-        	$this->assertEquals($domain, $cookie->getDomain());
+            $cookie = Zend_Http_Cookie::fromString($cstr);
+            if (! $cookie instanceof Zend_Http_Cookie) $this->fail('We didn\'t get a valid Cookie object');
+            $this->assertEquals($domain, $cookie->getDomain());
         }
     }
 
     /**
      * Make sure we get the correct domain when it's set in a reference URL
-     * 
+     *
      */
-    public function testGetDomainInRefUrl() 
+    public function testGetDomainInRefUrl()
     {
         $domains = array(
             'example.com', 'www.example.com', 'some.really.deep.domain.com'
         );
-    	
+
         foreach ($domains as $domain) {
-        	$cookie = Zend_Http_Cookie::fromString('foo=baz; path=/', 'http://' . $domain);
-        	if (! $cookie instanceof Zend_Http_Cookie) $this->fail('We didn\'t get a valid Cookie object');
-        	$this->assertEquals($domain, $cookie->getDomain());
+            $cookie = Zend_Http_Cookie::fromString('foo=baz; path=/', 'http://' . $domain);
+            if (! $cookie instanceof Zend_Http_Cookie) $this->fail('We didn\'t get a valid Cookie object');
+            $this->assertEquals($domain, $cookie->getDomain());
         }
     }
 
     /**
      * Make sure we get the correct path when it's set in the cookie string
      */
-    public function testGetPathInStr() 
+    public function testGetPathInStr()
     {
-    	$cookies = array(
-    	    'cookie=foo; domain=example.com' => '/',
+        $cookies = array(
+            'cookie=foo; domain=example.com' => '/',
             'cookie=foo; path=/foo/baz; expires=Tue, 21-Nov-2006 08:33:44 GMT; domain=.example.com;' => '/foo/baz',
             'cookie=foo; domain=some.really.deep.domain.com; path=/Space Out/; expires=Tue, 21-Nov-2006 08:33:44 GMT;' => '/Space Out/'
         );
-        
+
         foreach ($cookies as $cstr => $path) {
-        	$cookie = Zend_Http_Cookie::fromString($cstr);
-        	if (! $cookie instanceof Zend_Http_Cookie) $this->fail('Failed generatic a valid cookie object');
-        	$this->assertEquals($path, $cookie->getPath(), 'Cookie path is not as expected');
+            $cookie = Zend_Http_Cookie::fromString($cstr);
+            if (! $cookie instanceof Zend_Http_Cookie) $this->fail('Failed generatic a valid cookie object');
+            $this->assertEquals($path, $cookie->getPath(), 'Cookie path is not as expected');
         }
     }
 
     /**
      * Make sure we get the correct path when it's set a reference URL
      */
-    public function testGetPathInRefUrl() 
+    public function testGetPathInRefUrl()
     {
-    	$refUrls = array(
-    	    'http://www.example.com/foo/bar/' => '/foo/bar',
-    	    'http://foo.com'                 => '/',
-    	    'http://qua.qua.co.uk/path/to/very/deep/file.php' => '/path/to/very/deep'
-    	);
-    	
-    	foreach ($refUrls as $url => $path) {
-    		$cookie = Zend_Http_Cookie::fromString('foo=bar', $url);
-    		if (! $cookie instanceof Zend_Http_Cookie) $this->fail('Failed generating a valid cookie object');
-    		$this->assertEquals($path, $cookie->getPath(), 'Cookie path is not as expected');
-    	}
+        $refUrls = array(
+            'http://www.example.com/foo/bar/' => '/foo/bar',
+            'http://foo.com'                 => '/',
+            'http://qua.qua.co.uk/path/to/very/deep/file.php' => '/path/to/very/deep'
+        );
+
+        foreach ($refUrls as $url => $path) {
+            $cookie = Zend_Http_Cookie::fromString('foo=bar', $url);
+            if (! $cookie instanceof Zend_Http_Cookie) $this->fail('Failed generating a valid cookie object');
+            $this->assertEquals($path, $cookie->getPath(), 'Cookie path is not as expected');
+        }
     }
 
     /**
      * Test we get the correct expiry time
-     * 
+     *
      */
-    public function testGetExpiryTime() 
+    public function testGetExpiryTime()
     {
-    	$now = time();
-    	$yesterday = $now - (3600 * 24);
+        $now = time();
+        $yesterday = $now - (3600 * 24);
         $cookies = array(
             'cookie=bar; domain=example.com; expires=' . date(DATE_COOKIE, $now) . ';' => $now,
             'cookie=foo; expires=' . date(DATE_COOKIE, $yesterday) . '; domain=some.really.deep.domain.com; path=/;' => $yesterday,
             'cookie=baz; domain=foo.com; path=/some/path; secure' => null
         );
-        
+
         foreach ($cookies as $cstr => $exp) {
-        	$cookie = Zend_Http_Cookie::fromString($cstr);
-        	if (! $cookie) $this->fail('Got no cookie object from a valid cookie string');
-        	$this->assertEquals($exp, $cookie->getExpiryTime(), 'Expiry time is not as expected');
+            $cookie = Zend_Http_Cookie::fromString($cstr);
+            if (! $cookie) $this->fail('Got no cookie object from a valid cookie string');
+            $this->assertEquals($exp, $cookie->getExpiryTime(), 'Expiry time is not as expected');
         }
     }
 
     /**
      * Make sure the "is secure" flag is correctly set
      */
-    public function testIsSecure() 
+    public function testIsSecure()
     {
         $cookies = array(
             'cookie=foo; path=/foo/baz; secure; expires=Tue, 21-Nov-2006 08:33:44 GMT; domain=.example.com;' => true,
@@ -200,70 +200,70 @@ class Zend_Http_CookieTest extends PHPUnit_Framework_TestCase
             'cookie=foo; path=/; SECURE; domain=.example.com;' => true,
             'cookie=foo; path=/; domain=.example.com; SECURE' => true
         );
-        
+
         foreach ($cookies as $cstr => $secure) {
-        	$cookie = Zend_Http_Cookie::fromString($cstr);
-        	if (! $cookie) $this->fail('Got no cookie object from a valid cookie string');
-        	$this->assertEquals($secure, $cookie->isSecure(), 'isSecure is not as expected');
+            $cookie = Zend_Http_Cookie::fromString($cstr);
+            if (! $cookie) $this->fail('Got no cookie object from a valid cookie string');
+            $this->assertEquals($secure, $cookie->isSecure(), 'isSecure is not as expected');
         }
-        
+
     }
 
     /**
      * Make sure we get the correct value for 'isExpired'
      */
-    public function testIsExpired() 
+    public function testIsExpired()
     {
-		$notexpired = time() + 3600;
-		$expired = time() - 3600;
-		
-		$cookies = array(
-			'cookie=foo; domain=example.com; expires=' . date(DATE_COOKIE, $notexpired) => false,
-			'cookie=foo; domain=example.com; expires=' . date(DATE_COOKIE, $expired) => true,
-			'cookie=foo; domain=example.com;' => false
-		);
-		
-		foreach ($cookies as $cstr => $isexp) {
-			$cookie = Zend_Http_Cookie::fromString($cstr);
-			if (! $cookie) $this->fail('Got no cookie object from a valid cookie string');
-			$this->assertEquals($isexp, $cookie->isExpired(), 'Got the wrong value for isExpired()');
-		}
+        $notexpired = time() + 3600;
+        $expired = time() - 3600;
+
+        $cookies = array(
+            'cookie=foo; domain=example.com; expires=' . date(DATE_COOKIE, $notexpired) => false,
+            'cookie=foo; domain=example.com; expires=' . date(DATE_COOKIE, $expired) => true,
+            'cookie=foo; domain=example.com;' => false
+        );
+
+        foreach ($cookies as $cstr => $isexp) {
+            $cookie = Zend_Http_Cookie::fromString($cstr);
+            if (! $cookie) $this->fail('Got no cookie object from a valid cookie string');
+            $this->assertEquals($isexp, $cookie->isExpired(), 'Got the wrong value for isExpired()');
+        }
     }
 
     /**
      * Make sure we get the correct value for 'isExpired', when time is manually set
      */
-    public function testIsExpiredDifferentTime() 
+    public function testIsExpiredDifferentTime()
     {
-		$notexpired = time() + 3600;
-		$expired = time() - 3600;
-		$now = time() + 7200;
-		
-		$cookies = array(
-			'cookie=foo; domain=example.com; expires=' . date(DATE_COOKIE, $notexpired),
-			'cookie=foo; domain=example.com; expires=' . date(DATE_COOKIE, $expired)
-		);
-		
-		// Make sure all cookies are expired
-		foreach ($cookies as $cstr) {
-			$cookie = Zend_Http_Cookie::fromString($cstr);
-			if (! $cookie) $this->fail('Got no cookie object from a valid cookie string');
-			$this->assertTrue($cookie->isExpired($now), 'Cookie is expected to be expired');
-		}
-		
-		// Make sure all cookies are not expired
-		$now = time() - 7200;
-		foreach ($cookies as $cstr) {
-			$cookie = Zend_Http_Cookie::fromString($cstr);
-			if (! $cookie) $this->fail('Got no cookie object from a valid cookie string');
-			$this->assertFalse($cookie->isExpired($now), 'Cookie is expected not to be expired');
-		}
+        $notexpired = time() + 3600;
+        $expired = time() - 3600;
+        $now = time() + 7200;
+
+        $cookies = array(
+            'cookie=foo; domain=example.com; expires=' . date(DATE_COOKIE, $notexpired),
+            'cookie=foo; domain=example.com; expires=' . date(DATE_COOKIE, $expired)
+        );
+
+        // Make sure all cookies are expired
+        foreach ($cookies as $cstr) {
+            $cookie = Zend_Http_Cookie::fromString($cstr);
+            if (! $cookie) $this->fail('Got no cookie object from a valid cookie string');
+            $this->assertTrue($cookie->isExpired($now), 'Cookie is expected to be expired');
+        }
+
+        // Make sure all cookies are not expired
+        $now = time() - 7200;
+        foreach ($cookies as $cstr) {
+            $cookie = Zend_Http_Cookie::fromString($cstr);
+            if (! $cookie) $this->fail('Got no cookie object from a valid cookie string');
+            $this->assertFalse($cookie->isExpired($now), 'Cookie is expected not to be expired');
+        }
     }
 
     /**
      * Test we can properly check if a cookie is a session cookie (has no expiry time)
      */
-    public function testIsSessionCookie() 
+    public function testIsSessionCookie()
     {
         $cookies = array(
             'cookie=foo; path=/foo/baz; secure; expires=Tue, 21-Nov-2006 08:33:44 GMT; domain=.example.com;' => false,
@@ -271,99 +271,99 @@ class Zend_Http_CookieTest extends PHPUnit_Framework_TestCase
             'cookie=foo; path=/; secure; domain=.example.com;' => true,
             'cookie=foo; path=/; domain=.example.com; secure; expires=' . date(DATE_COOKIE) => false
         );
-        
+
         foreach ($cookies as $cstr => $issession) {
-        	$cookie = Zend_Http_Cookie::fromString($cstr);
-        	if (! $cookie) $this->fail('Got no cookie object from a valid cookie string');
-        	$this->assertEquals($issession, $cookie->isSessionCookie(), 'isSessionCookie is not as expected');
+            $cookie = Zend_Http_Cookie::fromString($cstr);
+            if (! $cookie) $this->fail('Got no cookie object from a valid cookie string');
+            $this->assertEquals($issession, $cookie->isSessionCookie(), 'isSessionCookie is not as expected');
         }
     }
 
     /**
      * Make sure cookies are properly converted back to strings
      */
-    public function testToString() 
+    public function testToString()
     {
-    	$cookies = array(
-    	    'name=value;',
-    	    'blank=;',
-    	    'urlencodedstuff=' . urlencode('!@#$)(@$%_+{} !@#?^&') . ';',    	
-    	);
-    	
-    	foreach ($cookies as $cstr) {
-    		$cookie = Zend_Http_Cookie::fromString($cstr, 'http://example.com');
-    		if (! $cookie) $this->fail('Got no cookie object from a valid cookie string');
-    		$this->assertEquals($cstr, $cookie->__toString(), 'Cookie is not converted back to the expected string');
-    	}
-    
+        $cookies = array(
+            'name=value;',
+            'blank=;',
+            'urlencodedstuff=' . urlencode('!@#$)(@$%_+{} !@#?^&') . ';',
+        );
+
+        foreach ($cookies as $cstr) {
+            $cookie = Zend_Http_Cookie::fromString($cstr, 'http://example.com');
+            if (! $cookie) $this->fail('Got no cookie object from a valid cookie string');
+            $this->assertEquals($cstr, $cookie->__toString(), 'Cookie is not converted back to the expected string');
+        }
+
     }
-    
+
     public function testGarbageInStrIsIgnored()
     {
-    	$cookies = array(
-    	    'name=value; domain=foo.com; silly=place; secure',
-    	    'foo=value; someCrap; secure; domain=foo.com; ',
-    	    'anothercookie=value; secure; has some crap; ignore=me; domain=foo.com; '
-    	);
-    	
-    	foreach ($cookies as $cstr) {
-    		$cookie = Zend_Http_Cookie::fromString($cstr);
-    		if (! $cookie) $this->fail('Got no cookie object from a valid cookie string');
-    		$this->assertEquals('value', $cookie->getValue(), 'Value is not as expected');
-    		$this->assertEquals('foo.com', $cookie->getDomain(), 'Domain is not as expected');
-    		$this->assertTrue($cookie->isSecure(), 'Cookie is expected to be secure');
-    	}
+        $cookies = array(
+            'name=value; domain=foo.com; silly=place; secure',
+            'foo=value; someCrap; secure; domain=foo.com; ',
+            'anothercookie=value; secure; has some crap; ignore=me; domain=foo.com; '
+        );
+
+        foreach ($cookies as $cstr) {
+            $cookie = Zend_Http_Cookie::fromString($cstr);
+            if (! $cookie) $this->fail('Got no cookie object from a valid cookie string');
+            $this->assertEquals('value', $cookie->getValue(), 'Value is not as expected');
+            $this->assertEquals('foo.com', $cookie->getDomain(), 'Domain is not as expected');
+            $this->assertTrue($cookie->isSecure(), 'Cookie is expected to be secure');
+        }
     }
 
     /**
      * Test the match() method against a domain
-     * 
+     *
      */
-    public function testMatchDomain() 
+    public function testMatchDomain()
     {
-    	$cookie = Zend_Http_Cookie::fromString('foo=bar; domain=.example.com;');
-    	$this->assertTrue($cookie->match('http://www.example.com/foo/bar.php'), 'Cookie expected to match, but didn\'t');
-    	$this->assertFalse($cookie->match('http://www.somexample.com/foo/bar.php'), 'Cookie expected not to match, but did');
-    	
-    	$uri = Zend_Uri::factory('http://www.foo.com/some/file.txt');
-    	$cookie = Zend_Http_Cookie::fromString('cookie=value; domain=www.foo.com');
-    	$this->assertTrue($cookie->match($uri), 'Cookie expected to match, but didn\'t');
-    	$this->assertTrue($cookie->match('http://il.www.foo.com'), 'Cookie expected to match, but didn\'t');
-    	$this->assertFalse($cookie->match('http://bar.foo.com'), 'Cookie expected not to match, but did');
+        $cookie = Zend_Http_Cookie::fromString('foo=bar; domain=.example.com;');
+        $this->assertTrue($cookie->match('http://www.example.com/foo/bar.php'), 'Cookie expected to match, but didn\'t');
+        $this->assertFalse($cookie->match('http://www.somexample.com/foo/bar.php'), 'Cookie expected not to match, but did');
+
+        $uri = Zend_Uri::factory('http://www.foo.com/some/file.txt');
+        $cookie = Zend_Http_Cookie::fromString('cookie=value; domain=www.foo.com');
+        $this->assertTrue($cookie->match($uri), 'Cookie expected to match, but didn\'t');
+        $this->assertTrue($cookie->match('http://il.www.foo.com'), 'Cookie expected to match, but didn\'t');
+        $this->assertFalse($cookie->match('http://bar.foo.com'), 'Cookie expected not to match, but did');
     }
-    
+
     /**
      * Test the match() method against a domain
-     * 
+     *
      */
-    public function testMatchPath() 
+    public function testMatchPath()
     {
-    	$cookie = Zend_Http_Cookie::fromString('foo=bar; domain=.example.com; path=/foo');
-    	$this->assertTrue($cookie->match('http://www.example.com/foo/bar.php'), 'Cookie expected to match, but didn\'t');
-    	$this->assertFalse($cookie->match('http://www.example.com/bar.php'), 'Cookie expected not to match, but did');
-    	
-    	$cookie = Zend_Http_Cookie::fromString('cookie=value; domain=www.foo.com; path=/some/long/path');
-    	$this->assertTrue($cookie->match('http://www.foo.com/some/long/path/file.txt'), 'Cookie expected to match, but didn\'t');
-    	$this->assertTrue($cookie->match('http://www.foo.com/some/long/path/and/even/more'), 'Cookie expected to match, but didn\'t');
-    	$this->assertFalse($cookie->match('http://www.foo.com/some/long/file.txt'), 'Cookie expected not to match, but did');
-    	$this->assertFalse($cookie->match('http://www.foo.com/some/different/path/file.txt'), 'Cookie expected not to match, but did');
+        $cookie = Zend_Http_Cookie::fromString('foo=bar; domain=.example.com; path=/foo');
+        $this->assertTrue($cookie->match('http://www.example.com/foo/bar.php'), 'Cookie expected to match, but didn\'t');
+        $this->assertFalse($cookie->match('http://www.example.com/bar.php'), 'Cookie expected not to match, but did');
+
+        $cookie = Zend_Http_Cookie::fromString('cookie=value; domain=www.foo.com; path=/some/long/path');
+        $this->assertTrue($cookie->match('http://www.foo.com/some/long/path/file.txt'), 'Cookie expected to match, but didn\'t');
+        $this->assertTrue($cookie->match('http://www.foo.com/some/long/path/and/even/more'), 'Cookie expected to match, but didn\'t');
+        $this->assertFalse($cookie->match('http://www.foo.com/some/long/file.txt'), 'Cookie expected not to match, but did');
+        $this->assertFalse($cookie->match('http://www.foo.com/some/different/path/file.txt'), 'Cookie expected not to match, but did');
     }
-    
+
     /**
      * Test the match() method against secure / non secure connections
      *
      */
     public function testMatchSecure()
     {
-    	// A non secure cookie, should match both
-    	$cookie = Zend_Http_Cookie::fromString('foo=bar; domain=.example.com;');
-    	$this->assertTrue($cookie->match('http://www.example.com/foo/bar.php'), 'Cookie expected to match, but didn\'t');
-    	$this->assertTrue($cookie->match('https://www.example.com/bar.php'), 'Cookie expected to match, but didn\'t');
-    	
-    	// A secure cookie, should match secure connections only
-    	$cookie = Zend_Http_Cookie::fromString('foo=bar; domain=.example.com; secure');
-    	$this->assertFalse($cookie->match('http://www.example.com/foo/bar.php'), 'Cookie expected not to match, but it did');
-    	$this->assertTrue($cookie->match('https://www.example.com/bar.php'), 'Cookie expected to match, but didn\'t');
+        // A non secure cookie, should match both
+        $cookie = Zend_Http_Cookie::fromString('foo=bar; domain=.example.com;');
+        $this->assertTrue($cookie->match('http://www.example.com/foo/bar.php'), 'Cookie expected to match, but didn\'t');
+        $this->assertTrue($cookie->match('https://www.example.com/bar.php'), 'Cookie expected to match, but didn\'t');
+
+        // A secure cookie, should match secure connections only
+        $cookie = Zend_Http_Cookie::fromString('foo=bar; domain=.example.com; secure');
+        $this->assertFalse($cookie->match('http://www.example.com/foo/bar.php'), 'Cookie expected not to match, but it did');
+        $this->assertTrue($cookie->match('https://www.example.com/bar.php'), 'Cookie expected to match, but didn\'t');
     }
 
     /**
@@ -372,41 +372,41 @@ class Zend_Http_CookieTest extends PHPUnit_Framework_TestCase
      */
     public function testMatchExpire()
     {
-    	// A session cookie - should always be valid
-    	$cookie = Zend_Http_Cookie::fromString('foo=bar; domain=.example.com;');
-    	$this->assertTrue($cookie->match('http://www.example.com/'), 'Cookie expected to match, but didn\'t');
-    	$this->assertTrue($cookie->match('http://www.example.com/', true, time() + 3600), 'Cookie expected to match, but didn\'t');
-    	
-    	// A session cookie, should not match
-    	$this->assertFalse($cookie->match('https://www.example.com/', false), 'Cookie expected not to match, but it did');
-    	$this->assertFalse($cookie->match('https://www.example.com/', false, time() - 3600), 'Cookie expected not to match, but it did');
-    	
-    	// A cookie with expiry time in the future
-    	$cookie = Zend_Http_Cookie::fromString('foo=bar; domain=.example.com; expires=' . date(DATE_COOKIE, time() + 3600));
-    	$this->assertTrue($cookie->match('http://www.example.com/'), 'Cookie expected to match, but didn\'t');
-    	$this->assertFalse($cookie->match('https://www.example.com/', true, time() + 7200), 'Cookie expected not to match, but it did');
-    	
-    	// A cookie with expiry time in the past
-    	$cookie = Zend_Http_Cookie::fromString('foo=bar; domain=.example.com; expires=' . date(DATE_COOKIE, time() - 3600));
-    	$this->assertFalse($cookie->match('http://www.example.com/'), 'Cookie expected not to match, but it did');
-    	$this->assertTrue($cookie->match('https://www.example.com/', true, time() - 7200), 'Cookie expected to match, but didn\'t');
+        // A session cookie - should always be valid
+        $cookie = Zend_Http_Cookie::fromString('foo=bar; domain=.example.com;');
+        $this->assertTrue($cookie->match('http://www.example.com/'), 'Cookie expected to match, but didn\'t');
+        $this->assertTrue($cookie->match('http://www.example.com/', true, time() + 3600), 'Cookie expected to match, but didn\'t');
+
+        // A session cookie, should not match
+        $this->assertFalse($cookie->match('https://www.example.com/', false), 'Cookie expected not to match, but it did');
+        $this->assertFalse($cookie->match('https://www.example.com/', false, time() - 3600), 'Cookie expected not to match, but it did');
+
+        // A cookie with expiry time in the future
+        $cookie = Zend_Http_Cookie::fromString('foo=bar; domain=.example.com; expires=' . date(DATE_COOKIE, time() + 3600));
+        $this->assertTrue($cookie->match('http://www.example.com/'), 'Cookie expected to match, but didn\'t');
+        $this->assertFalse($cookie->match('https://www.example.com/', true, time() + 7200), 'Cookie expected not to match, but it did');
+
+        // A cookie with expiry time in the past
+        $cookie = Zend_Http_Cookie::fromString('foo=bar; domain=.example.com; expires=' . date(DATE_COOKIE, time() - 3600));
+        $this->assertFalse($cookie->match('http://www.example.com/'), 'Cookie expected not to match, but it did');
+        $this->assertTrue($cookie->match('https://www.example.com/', true, time() - 7200), 'Cookie expected to match, but didn\'t');
     }
 
     public function testFromStringFalse()
     {
         $cookie = Zend_Http_Cookie::fromString('foo; domain=www.exmaple.com');
         $this->assertEquals(false, $cookie, 'fromString was expected to fail and return false');
-        
+
         $cookie = Zend_Http_Cookie::fromString('=bar; secure; domain=foo.nl');
         $this->assertEquals(false, $cookie, 'fromString was expected to fail and return false');
-        
+
         $cookie = Zend_Http_Cookie::fromString('fo;o=bar; secure; domain=foo.nl');
         $this->assertEquals(false, $cookie, 'fromString was expected to fail and return false');
     }
-    
+
     /**
      * Test that cookies with far future expiry date (beyond the 32 bit unsigned int range) are
-     * not mistakenly marked as 'expired' 
+     * not mistakenly marked as 'expired'
      *
      * @link http://framework.zend.com/issues/browse/ZF-5690
      */
@@ -414,6 +414,6 @@ class Zend_Http_CookieTest extends PHPUnit_Framework_TestCase
     {
         $expTime = "Sat, 29-Jan-2039 00:54:42 GMT";
         $cookie = Zend_Http_Cookie::fromString("foo=bar; domain=.example.com; expires=$expTime");
-        $this->assertFalse($cookie->isExpired(), 'Expiry: ' . $cookie->getExpiryTime()); 
+        $this->assertFalse($cookie->isExpired(), 'Expiry: ' . $cookie->getExpiryTime());
     }
 }

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

@@ -26,7 +26,7 @@ require_once 'PHPUnit/Framework/TestCase.php';
 
 /**
  * Zend_Http_Response unit tests
- * 
+ *
  * @category   Zend
  * @package    Zend_Http
  * @subpackage UnitTests
@@ -35,241 +35,241 @@ require_once 'PHPUnit/Framework/TestCase.php';
  */
 class Zend_Http_ResponseTest extends PHPUnit_Framework_TestCase
 {
-	public function setUp()
-	{ }
-	
-	public function testGzipResponse ()
-	{
-		$response_text = file_get_contents(dirname(__FILE__) . '/_files/response_gzip');
-		
-		$res = Zend_Http_Response::fromString($response_text);
-		
-		$this->assertEquals('gzip', $res->getHeader('Content-encoding'));
-		$this->assertEquals('0b13cb193de9450aa70a6403e2c9902f', md5($res->getBody()));
-		$this->assertEquals('f24dd075ba2ebfb3bf21270e3fdc5303', md5($res->getRawBody()));
-	}
-		
-	public function testDeflateResponse ()
-	{
-		$response_text = file_get_contents(dirname(__FILE__) . '/_files/response_deflate');
-		
-		$res = Zend_Http_Response::fromString($response_text);
-		
-		$this->assertEquals('deflate', $res->getHeader('Content-encoding'));
-		$this->assertEquals('0b13cb193de9450aa70a6403e2c9902f', md5($res->getBody()));
-		$this->assertEquals('ad62c21c3aa77b6a6f39600f6dd553b8', md5($res->getRawBody()));
-	}
-			
-	public function testChunkedResponse ()
-	{
-		$response_text = file_get_contents(dirname(__FILE__) . '/_files/response_chunked');
-		
-		$res = Zend_Http_Response::fromString($response_text);
-		
-		$this->assertEquals('chunked', $res->getHeader('Transfer-encoding'));
-		$this->assertEquals('0b13cb193de9450aa70a6403e2c9902f', md5($res->getBody()));
-		$this->assertEquals('c0cc9d44790fa2a58078059bab1902a9', md5($res->getRawBody()));
-	}
-	
-	public function testLineBreaksCompatibility()
-	{
-		$response_text_lf = $this->readResponse('response_lfonly');
-		$res_lf = Zend_Http_Response::fromString($response_text_lf);
-		
-		$response_text_crlf = $this->readResponse('response_crlf');
-		$res_crlf = Zend_Http_Response::fromString($response_text_crlf);
-		
-		$this->assertEquals($res_lf->getHeadersAsString(true), $res_crlf->getHeadersAsString(true), 'Responses headers do not match');
-		$this->assertEquals($res_lf->getBody(), $res_crlf->getBody(), 'Response bodies do not match');
-	}
-	
-	public function testExtractMessageCrlf()
-	{
-		$response_text = file_get_contents(dirname(__FILE__) . '/_files/response_crlf');
-		$this->assertEquals("OK", Zend_Http_Response::extractMessage($response_text), "Response message is not 'OK' as expected");
-	}
-	
-	public function testExtractMessageLfonly()
-	{
-		$response_text = file_get_contents(dirname(__FILE__) . '/_files/response_lfonly');
-		$this->assertEquals("OK", Zend_Http_Response::extractMessage($response_text), "Response message is not 'OK' as expected");
-	}
-	
-	public function test404IsError()
-	{
-		$response_text = $this->readResponse('response_404');
-		$response = Zend_Http_Response::fromString($response_text);
-		
-		$this->assertEquals(404, $response->getStatus(), 'Response code is expected to be 404, but it\'s not.');
-		$this->assertTrue($response->isError(), 'Response is an error, but isError() returned false');
-		$this->assertFalse($response->isSuccessful(), 'Response is an error, but isSuccessful() returned true');
-		$this->assertFalse($response->isRedirect(), 'Response is an error, but isRedirect() returned true');
-	}
-
-	public function test500isError()
-	{
-		$response_text = $this->readResponse('response_500');
-		$response = Zend_Http_Response::fromString($response_text);
-		
-		$this->assertEquals(500, $response->getStatus(), 'Response code is expected to be 500, but it\'s not.');
-		$this->assertTrue($response->isError(), 'Response is an error, but isError() returned false');
-		$this->assertFalse($response->isSuccessful(), 'Response is an error, but isSuccessful() returned true');
-		$this->assertFalse($response->isRedirect(), 'Response is an error, but isRedirect() returned true');
-	}
-	
-	public function test300isRedirect()
-	{
-		$response = Zend_Http_Response::fromString($this->readResponse('response_302'));
-
-		$this->assertEquals(302, $response->getStatus(), 'Response code is expected to be 302, but it\'s not.');
-		$this->assertTrue($response->isRedirect(), 'Response is a redirection, but isRedirect() returned false');
-		$this->assertFalse($response->isError(), 'Response is a redirection, but isError() returned true');
-		$this->assertFalse($response->isSuccessful(), 'Response is a redirection, but isSuccessful() returned true');
-	}
-	
-	public function test200Ok()
-	{
-		$response = Zend_Http_Response::fromString($this->readResponse('response_deflate'));
-		
-		$this->assertEquals(200, $response->getStatus(), 'Response code is expected to be 200, but it\'s not.');
-		$this->assertFalse($response->isError(), 'Response is OK, but isError() returned true');
-		$this->assertTrue($response->isSuccessful(), 'Response is OK, but isSuccessful() returned false');
-		$this->assertFalse($response->isRedirect(), 'Response is OK, but isRedirect() returned true');
-	}
-	
-	public function test100Continue()
-	{
-		$this->markTestIncomplete();	
-	}
-	
-	public function testAutoMessageSet()
-	{
-		$response = Zend_Http_Response::fromString($this->readResponse('response_403_nomessage'));
-		
-		$this->assertEquals(403, $response->getStatus(), 'Response status is expected to be 403, but it isn\'t');
-		$this->assertEquals('Forbidden', $response->getMessage(), 'Response is 403, but message is not "Forbidden" as expected');
-
-		// While we're here, make sure it's classified as error...
-		$this->assertTrue($response->isError(), 'Response is an error, but isError() returned false');
-		$this->assertFalse($response->isSuccessful(), 'Response is an error, but isSuccessful() returned true');
-		$this->assertFalse($response->isRedirect(), 'Response is an error, but isRedirect() returned true');
-	}
-	
-	public function testAsString()
-	{
-		$response_str = $this->readResponse('response_404');
-		$response = Zend_Http_Response::fromString($response_str);
-		
-		$this->assertEquals(strtolower($response_str), strtolower($response->asString()), 'Response convertion to string does not match original string');
-		$this->assertEquals(strtolower($response_str), strtolower((string)$response), 'Response convertion to string does not match original string');
-	}
-	
-	public function testGetHeaders()
-	{
-		$response = Zend_Http_Response::fromString($this->readResponse('response_deflate'));
-		$headers = $response->getHeaders();
-		
-		$this->assertEquals(8, count($headers), 'Header count is not as expected');
-		$this->assertEquals('Apache', $headers['Server'], 'Server header is not as expected');
-		$this->assertEquals('deflate', $headers['Content-encoding'], 'Content-type header is not as expected');
-	}
-	
-	public function testGetVersion()
-	{
-		$response = Zend_Http_Response::fromString($this->readResponse('response_chunked'));
-		$this->assertEquals(1.1, $response->getVersion(), 'Version is expected to be 1.1');
-	}
-	
-	public function testResponseCodeAsText()
-	{
-		// This is an entirely static test
-		
-		// Test some response codes
-		$this->assertEquals('Continue', Zend_Http_Response::responseCodeAsText(100));
-		$this->assertEquals('OK', Zend_Http_Response::responseCodeAsText(200));
-		$this->assertEquals('Multiple Choices', Zend_Http_Response::responseCodeAsText(300));
-		$this->assertEquals('Bad Request', Zend_Http_Response::responseCodeAsText(400));
-		$this->assertEquals('Internal Server Error', Zend_Http_Response::responseCodeAsText(500));
-		
-		// Make sure that invalid codes return 'Unkown'
-		$this->assertEquals('Unknown', Zend_Http_Response::responseCodeAsText(600));
-		
-		// Check HTTP/1.0 value for 302
-		$this->assertEquals('Found', Zend_Http_Response::responseCodeAsText(302));
-		$this->assertEquals('Moved Temporarily', Zend_Http_Response::responseCodeAsText(302, false));
-		
-		// Check we get an array if no code is passed
-		$codes = Zend_Http_Response::responseCodeAsText();
-		$this->assertType('array', $codes);
-		$this->assertEquals('OK', $codes[200]);
-	}
-	
-	public function testUnknownCode()
-	{
-		$response_str = $this->readResponse('response_unknown');
-		$response = Zend_Http_Response::fromString($response_str);
-		
-		// Check that dynamically the message is parsed 
-		$this->assertEquals(550, $response->getStatus(), 'Status is expected to be a non-standard 550');
-		$this->assertEquals('Printer On Fire', $response->getMessage(), 'Message is expected to be extracted');
-		
-		// Check that statically, an Unknown string is returned for the 550 code
-		$this->assertEquals('Unknown', Zend_Http_Response::responseCodeAsText($response_str));
-	}
-	
-	public function testMultilineHeader()
-	{
-		$response = Zend_Http_Response::fromString($this->readResponse('response_multiline_header'));
-		
-		// Make sure we got the corrent no. of headers
-		$this->assertEquals(6, count($response->getHeaders()), 'Header count is expected to be 6');
-		
-		// Check header integrity
-		$this->assertEquals('timeout=15, max=100', $response->getHeader('keep-alive'));
-		$this->assertEquals('text/html; charset=iso-8859-1', $response->getHeader('content-type'));
-	}
-	
-	public function testExceptInvalidChunkedBody()
-	{
-		try {
-			Zend_Http_Response::decodeChunkedBody($this->readResponse('response_deflate'));
-			$this->fail('An expected exception was not thrown');
-		} catch (Zend_Http_Exception $e) {
-			// We are ok!
-		}
-	}
-	
-	public function testExtractorsOnInvalidString()
-	{
-		// Try with an empty string
-		$response_str = '';
-		
-		$this->assertTrue(Zend_Http_Response::extractCode($response_str) === false);
-		$this->assertTrue(Zend_Http_Response::extractMessage($response_str) === false);
-		$this->assertTrue(Zend_Http_Response::extractVersion($response_str) === false);
-		$this->assertTrue(Zend_Http_Response::extractBody($response_str) === '');
-		$this->assertTrue(Zend_Http_Response::extractHeaders($response_str) === array());
-	}
-
-	/**
-	 * Make sure a response with some leading whitespace in the response body
-	 * does not get modified (see ZF-1924)
-	 *
-	 */
-	public function testLeadingWhitespaceBody()
-	{
-		$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');
-	}
-	
-	/**
-	 * Helper function: read test response from file
-	 *
-	 * @param string $response
-	 * @return string
-	 */
-	protected function readResponse($response)
-	{
-		return file_get_contents(dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . $response);
-	}
+    public function setUp()
+    { }
+
+    public function testGzipResponse ()
+    {
+        $response_text = file_get_contents(dirname(__FILE__) . '/_files/response_gzip');
+
+        $res = Zend_Http_Response::fromString($response_text);
+
+        $this->assertEquals('gzip', $res->getHeader('Content-encoding'));
+        $this->assertEquals('0b13cb193de9450aa70a6403e2c9902f', md5($res->getBody()));
+        $this->assertEquals('f24dd075ba2ebfb3bf21270e3fdc5303', md5($res->getRawBody()));
+    }
+
+    public function testDeflateResponse ()
+    {
+        $response_text = file_get_contents(dirname(__FILE__) . '/_files/response_deflate');
+
+        $res = Zend_Http_Response::fromString($response_text);
+
+        $this->assertEquals('deflate', $res->getHeader('Content-encoding'));
+        $this->assertEquals('0b13cb193de9450aa70a6403e2c9902f', md5($res->getBody()));
+        $this->assertEquals('ad62c21c3aa77b6a6f39600f6dd553b8', md5($res->getRawBody()));
+    }
+
+    public function testChunkedResponse ()
+    {
+        $response_text = file_get_contents(dirname(__FILE__) . '/_files/response_chunked');
+
+        $res = Zend_Http_Response::fromString($response_text);
+
+        $this->assertEquals('chunked', $res->getHeader('Transfer-encoding'));
+        $this->assertEquals('0b13cb193de9450aa70a6403e2c9902f', md5($res->getBody()));
+        $this->assertEquals('c0cc9d44790fa2a58078059bab1902a9', md5($res->getRawBody()));
+    }
+
+    public function testLineBreaksCompatibility()
+    {
+        $response_text_lf = $this->readResponse('response_lfonly');
+        $res_lf = Zend_Http_Response::fromString($response_text_lf);
+
+        $response_text_crlf = $this->readResponse('response_crlf');
+        $res_crlf = Zend_Http_Response::fromString($response_text_crlf);
+
+        $this->assertEquals($res_lf->getHeadersAsString(true), $res_crlf->getHeadersAsString(true), 'Responses headers do not match');
+        $this->assertEquals($res_lf->getBody(), $res_crlf->getBody(), 'Response bodies do not match');
+    }
+
+    public function testExtractMessageCrlf()
+    {
+        $response_text = file_get_contents(dirname(__FILE__) . '/_files/response_crlf');
+        $this->assertEquals("OK", Zend_Http_Response::extractMessage($response_text), "Response message is not 'OK' as expected");
+    }
+
+    public function testExtractMessageLfonly()
+    {
+        $response_text = file_get_contents(dirname(__FILE__) . '/_files/response_lfonly');
+        $this->assertEquals("OK", Zend_Http_Response::extractMessage($response_text), "Response message is not 'OK' as expected");
+    }
+
+    public function test404IsError()
+    {
+        $response_text = $this->readResponse('response_404');
+        $response = Zend_Http_Response::fromString($response_text);
+
+        $this->assertEquals(404, $response->getStatus(), 'Response code is expected to be 404, but it\'s not.');
+        $this->assertTrue($response->isError(), 'Response is an error, but isError() returned false');
+        $this->assertFalse($response->isSuccessful(), 'Response is an error, but isSuccessful() returned true');
+        $this->assertFalse($response->isRedirect(), 'Response is an error, but isRedirect() returned true');
+    }
+
+    public function test500isError()
+    {
+        $response_text = $this->readResponse('response_500');
+        $response = Zend_Http_Response::fromString($response_text);
+
+        $this->assertEquals(500, $response->getStatus(), 'Response code is expected to be 500, but it\'s not.');
+        $this->assertTrue($response->isError(), 'Response is an error, but isError() returned false');
+        $this->assertFalse($response->isSuccessful(), 'Response is an error, but isSuccessful() returned true');
+        $this->assertFalse($response->isRedirect(), 'Response is an error, but isRedirect() returned true');
+    }
+
+    public function test300isRedirect()
+    {
+        $response = Zend_Http_Response::fromString($this->readResponse('response_302'));
+
+        $this->assertEquals(302, $response->getStatus(), 'Response code is expected to be 302, but it\'s not.');
+        $this->assertTrue($response->isRedirect(), 'Response is a redirection, but isRedirect() returned false');
+        $this->assertFalse($response->isError(), 'Response is a redirection, but isError() returned true');
+        $this->assertFalse($response->isSuccessful(), 'Response is a redirection, but isSuccessful() returned true');
+    }
+
+    public function test200Ok()
+    {
+        $response = Zend_Http_Response::fromString($this->readResponse('response_deflate'));
+
+        $this->assertEquals(200, $response->getStatus(), 'Response code is expected to be 200, but it\'s not.');
+        $this->assertFalse($response->isError(), 'Response is OK, but isError() returned true');
+        $this->assertTrue($response->isSuccessful(), 'Response is OK, but isSuccessful() returned false');
+        $this->assertFalse($response->isRedirect(), 'Response is OK, but isRedirect() returned true');
+    }
+
+    public function test100Continue()
+    {
+        $this->markTestIncomplete();
+    }
+
+    public function testAutoMessageSet()
+    {
+        $response = Zend_Http_Response::fromString($this->readResponse('response_403_nomessage'));
+
+        $this->assertEquals(403, $response->getStatus(), 'Response status is expected to be 403, but it isn\'t');
+        $this->assertEquals('Forbidden', $response->getMessage(), 'Response is 403, but message is not "Forbidden" as expected');
+
+        // While we're here, make sure it's classified as error...
+        $this->assertTrue($response->isError(), 'Response is an error, but isError() returned false');
+        $this->assertFalse($response->isSuccessful(), 'Response is an error, but isSuccessful() returned true');
+        $this->assertFalse($response->isRedirect(), 'Response is an error, but isRedirect() returned true');
+    }
+
+    public function testAsString()
+    {
+        $response_str = $this->readResponse('response_404');
+        $response = Zend_Http_Response::fromString($response_str);
+
+        $this->assertEquals(strtolower($response_str), strtolower($response->asString()), 'Response convertion to string does not match original string');
+        $this->assertEquals(strtolower($response_str), strtolower((string)$response), 'Response convertion to string does not match original string');
+    }
+
+    public function testGetHeaders()
+    {
+        $response = Zend_Http_Response::fromString($this->readResponse('response_deflate'));
+        $headers = $response->getHeaders();
+
+        $this->assertEquals(8, count($headers), 'Header count is not as expected');
+        $this->assertEquals('Apache', $headers['Server'], 'Server header is not as expected');
+        $this->assertEquals('deflate', $headers['Content-encoding'], 'Content-type header is not as expected');
+    }
+
+    public function testGetVersion()
+    {
+        $response = Zend_Http_Response::fromString($this->readResponse('response_chunked'));
+        $this->assertEquals(1.1, $response->getVersion(), 'Version is expected to be 1.1');
+    }
+
+    public function testResponseCodeAsText()
+    {
+        // This is an entirely static test
+
+        // Test some response codes
+        $this->assertEquals('Continue', Zend_Http_Response::responseCodeAsText(100));
+        $this->assertEquals('OK', Zend_Http_Response::responseCodeAsText(200));
+        $this->assertEquals('Multiple Choices', Zend_Http_Response::responseCodeAsText(300));
+        $this->assertEquals('Bad Request', Zend_Http_Response::responseCodeAsText(400));
+        $this->assertEquals('Internal Server Error', Zend_Http_Response::responseCodeAsText(500));
+
+        // Make sure that invalid codes return 'Unkown'
+        $this->assertEquals('Unknown', Zend_Http_Response::responseCodeAsText(600));
+
+        // Check HTTP/1.0 value for 302
+        $this->assertEquals('Found', Zend_Http_Response::responseCodeAsText(302));
+        $this->assertEquals('Moved Temporarily', Zend_Http_Response::responseCodeAsText(302, false));
+
+        // Check we get an array if no code is passed
+        $codes = Zend_Http_Response::responseCodeAsText();
+        $this->assertType('array', $codes);
+        $this->assertEquals('OK', $codes[200]);
+    }
+
+    public function testUnknownCode()
+    {
+        $response_str = $this->readResponse('response_unknown');
+        $response = Zend_Http_Response::fromString($response_str);
+
+        // Check that dynamically the message is parsed
+        $this->assertEquals(550, $response->getStatus(), 'Status is expected to be a non-standard 550');
+        $this->assertEquals('Printer On Fire', $response->getMessage(), 'Message is expected to be extracted');
+
+        // Check that statically, an Unknown string is returned for the 550 code
+        $this->assertEquals('Unknown', Zend_Http_Response::responseCodeAsText($response_str));
+    }
+
+    public function testMultilineHeader()
+    {
+        $response = Zend_Http_Response::fromString($this->readResponse('response_multiline_header'));
+
+        // Make sure we got the corrent no. of headers
+        $this->assertEquals(6, count($response->getHeaders()), 'Header count is expected to be 6');
+
+        // Check header integrity
+        $this->assertEquals('timeout=15, max=100', $response->getHeader('keep-alive'));
+        $this->assertEquals('text/html; charset=iso-8859-1', $response->getHeader('content-type'));
+    }
+
+    public function testExceptInvalidChunkedBody()
+    {
+        try {
+            Zend_Http_Response::decodeChunkedBody($this->readResponse('response_deflate'));
+            $this->fail('An expected exception was not thrown');
+        } catch (Zend_Http_Exception $e) {
+            // We are ok!
+        }
+    }
+
+    public function testExtractorsOnInvalidString()
+    {
+        // Try with an empty string
+        $response_str = '';
+
+        $this->assertTrue(Zend_Http_Response::extractCode($response_str) === false);
+        $this->assertTrue(Zend_Http_Response::extractMessage($response_str) === false);
+        $this->assertTrue(Zend_Http_Response::extractVersion($response_str) === false);
+        $this->assertTrue(Zend_Http_Response::extractBody($response_str) === '');
+        $this->assertTrue(Zend_Http_Response::extractHeaders($response_str) === array());
+    }
+
+    /**
+     * Make sure a response with some leading whitespace in the response body
+     * does not get modified (see ZF-1924)
+     *
+     */
+    public function testLeadingWhitespaceBody()
+    {
+        $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');
+    }
+
+    /**
+     * Helper function: read test response from file
+     *
+     * @param string $response
+     * @return string
+     */
+    protected function readResponse($response)
+    {
+        return file_get_contents(dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . $response);
+    }
 }