From: Chuck Hagenbuch Date: Sat, 22 Jan 2011 03:36:57 +0000 (-0500) Subject: Make getBody() repeatable X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=4e44faf8092fe079379bec349b2a021a67fe130d;p=horde.git Make getBody() repeatable --- diff --git a/framework/Http/lib/Horde/Http/Response/Fopen.php b/framework/Http/lib/Horde/Http/Response/Fopen.php index e681069f3..28ce5af7d 100644 --- a/framework/Http/lib/Horde/Http/Response/Fopen.php +++ b/framework/Http/lib/Horde/Http/Response/Fopen.php @@ -24,6 +24,11 @@ class Horde_Http_Response_Fopen extends Horde_Http_Response_Base protected $_stream; /** + * Response content + */ + protected $_content; + + /** * Constructor. */ public function __construct($uri, $stream, $headers = array()) @@ -41,17 +46,21 @@ class Horde_Http_Response_Fopen extends Horde_Http_Response_Base */ public function getBody() { - $oldTrackErrors = ini_set('track_errors', 1); - $content = @stream_get_contents($this->_stream); - ini_set('track_errors', $oldTrackErrors); - if ($content === false) { - $msg = 'Problem reading data from ' . $this->uri; - if (isset($php_errormsg)) { - $msg .= ': ' . $php_errormsg; + if (is_null($this->_content)) { + $oldTrackErrors = ini_set('track_errors', 1); + $content = @stream_get_contents($this->_stream); + ini_set('track_errors', $oldTrackErrors); + if ($content === false) { + $msg = 'Problem reading data from ' . $this->uri; + if (isset($php_errormsg)) { + $msg .= ': ' . $php_errormsg; + } + throw new Horde_Http_Exception($msg); } - throw new Horde_Http_Exception($msg); + $this->_content = $content; } - return $content; + + return $this->_content; } /**