/** * Append response body * * @param string $body Content to append to the current HTTP response body * @param bool $overwrite Clear the existing body before writing new content? * @api */ public function write($body, $overwrite = false) { if ($overwrite === true) { $this->body->close(); $this->body = new \Guzzle\Stream\Stream(fopen('php://temp', 'r+')); } $this->body->write($body); }
/** * {@inheritdoc} */ protected function doWrite($string) { return $this->stream->write($string); }
/** * Constructor * * @param \Slim\Interfaces\EnvironmentInterface $env * @param \Slim\Interfaces\Http\HeadersInterface $headers * @param \Slim\Interfaces\Http\CookiesInterface $cookies * @param string $body * @api */ public function __construct(EnvironmentInterface $env, HeadersInterface $headers, CookiesInterface $cookies, $body = null) { $this->env = $env; $this->headers = $headers; $this->cookies = $cookies; $this->bodyRaw = new \Guzzle\Stream\Stream(fopen('php://temp', 'r+')); if (is_string($body) === true) { $this->bodyRaw->write($body); } $this->bodyRaw->seek(0); }