Quellcode durchsuchen

ZF-9206 Zend_Http_Client throws a warning, when using 'php://output' as destination stream

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@24336 44c647ce-9c0f-0410-b52a-842ac1e357ba
ezimuel vor 14 Jahren
Ursprung
Commit
7968304e81
2 geänderte Dateien mit 16 neuen und 2 gelöschten Zeilen
  1. 4 1
      library/Zend/Http/Client.php
  2. 12 1
      tests/Zend/Http/Client/StaticTest.php

+ 4 - 1
library/Zend/Http/Client.php

@@ -1026,7 +1026,10 @@ class Zend_Http_Client
             }
 
             if($this->config['output_stream']) {
-                rewind($stream);
+                $streamMetaData = stream_get_meta_data($stream);
+                if ($streamMetaData['seekable']) {
+                    rewind($stream);
+                }
                 // cleanup the adapter
                 $this->adapter->setOutputStream(null);
                 $response = Zend_Http_Response_Stream::fromStream($response, $stream);

+ 12 - 1
tests/Zend/Http/Client/StaticTest.php

@@ -715,7 +715,18 @@ RESPONSE
         $client = new Zend_Http_Client($uri);
         $this->assertEquals((string)$orig, (string)$uri);
     }
-    
+    /*
+     * @group ZF-9206
+     */
+    function testStreamWarningRewind()
+    {
+        $httpClient = new Zend_Http_Client();
+        $httpClient->setUri('http://example.org');
+        $httpClient->setMethod(Zend_Http_Client::GET);
+        ob_start();
+        $httpClient->setStream('php://output')->request();
+        ob_clean();
+    }
     /**
      * Data providers
      */