protected $_stream;
/**
+ * Response content
+ */
+ protected $_content;
+
+ /**
* Constructor.
*/
public function __construct($uri, $stream, $headers = array())
*/
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;
}
/**