浏览代码

ZF-1897
Zend_XmlRpc
Resolved issue with leading/trailing whitespace in chunked HTTP response


git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@24150 44c647ce-9c0f-0410-b52a-842ac1e357ba

adamlundrigan 14 年之前
父节点
当前提交
7ae7583fbf

+ 1 - 1
library/Zend/XmlRpc/Client.php

@@ -294,7 +294,7 @@ class Zend_XmlRpc_Client
             $response = new Zend_XmlRpc_Response();
         }
         $this->_lastResponse = $response;
-        $this->_lastResponse->loadXml($httpResponse->getBody());
+        $this->_lastResponse->loadXml(trim($httpResponse->getBody()));
     }
 
     /**

+ 18 - 0
tests/Zend/XmlRpc/ClientTest.php

@@ -717,6 +717,24 @@ class Zend_XmlRpc_ClientTest extends PHPUnit_Framework_TestCase
               $this->xmlrpcClient->call('get', array(1))
           );
     }
+    
+    /**
+     * @group ZF-1897
+     */
+    public function testHandlesLeadingOrTrailingWhitespaceInChunkedResponseProperly()
+    {
+        $baseUri = "http://foo:80";
+        $this->httpAdapter = new Zend_Http_Client_Adapter_Test();
+        $this->httpClient = new Zend_Http_Client(null, array('adapter' => $this->httpAdapter));
+        
+        $respBody = file_get_contents(dirname(__FILE__) . "/_files/ZF1897-response-chunked.txt");
+        $this->httpAdapter->setResponse($respBody);
+
+        $this->xmlrpcClient = new Zend_XmlRpc_Client($baseUri);
+        $this->xmlrpcClient->setHttpClient($this->httpClient);
+        
+        $this->assertEquals('FOO', $this->xmlrpcClient->call('foo'));
+    }
 
     // Helpers
     public function setServerResponseTo($nativeVars)

+ 22 - 0
tests/Zend/XmlRpc/_files/ZF1897-response-chunked.txt

@@ -0,0 +1,22 @@
+HTTP/1.1 200 OK
+Date: Thu, 06 Sep 2007 14:58:44 GMT
+Server: Apache/2.0.54 (Debian GNU/Linux) DAV/2 SVN/1.1.4 mod_python/3.1.3 Python/2.3.5 mod_ssl/2.0.54 OpenSSL/0.9.7e PHP/5.1.6
+X-Powered-By: PHP/5.1.6
+Connection: close
+Transfer-Encoding: chunked
+Content-Type: text/html; charset=iso-8859-1
+
+92 
+
+ 
+<?xml version="1.0"?>
+<methodResponse>
+  <params>
+    <param>
+      <value>FOO</value>
+    </param>
+  </params>
+</methodResponse>
+ 
+0 
+