From f3f05f6cc4bef3338dbfb6eb340da4fb1c5ba1e1 Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Sat, 11 Aug 2018 15:05:55 +0200 Subject: Make Engelsystem\Http\Response PSR-7 compatible --- src/helpers.php | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'src/helpers.php') diff --git a/src/helpers.php b/src/helpers.php index 2a90dcde..01fb10bd 100644 --- a/src/helpers.php +++ b/src/helpers.php @@ -4,11 +4,10 @@ use Engelsystem\Application; use Engelsystem\Config\Config; use Engelsystem\Http\Request; +use Engelsystem\Http\Response; use Engelsystem\Renderer\Renderer; use Engelsystem\Routing\UrlGenerator; -use Psr\Http\Message\ResponseInterface; use Symfony\Component\HttpFoundation\Session\SessionInterface; -use Zend\Diactoros\Stream; /** * Get the global app instance @@ -86,21 +85,16 @@ function request($key = null, $default = null) * @param string $content * @param int $status * @param array $headers - * @return ResponseInterface + * @return Response */ function response($content = '', $status = 200, $headers = []) { - /** @var ResponseInterface $response */ + /** @var Response $response */ $response = app('psr7.response'); - - /** @var Stream $stream */ - $stream = app()->make(Stream::class, ['stream' => 'php://memory', 'mode' => 'wb+']); - $stream->write($content); - $stream->rewind(); - $response = $response - ->withBody($stream) + ->withContent($content) ->withStatus($status); + foreach ($headers as $key => $value) { $response = $response->withAddedHeader($key, $value); } -- cgit v1.2.3-54-g00ecf