diff --git a/src/Illuminate/Laravel.php b/src/Illuminate/Laravel.php index b9ca35a9..7e3ab643 100644 --- a/src/Illuminate/Laravel.php +++ b/src/Illuminate/Laravel.php @@ -8,7 +8,6 @@ use Illuminate\Http\Request as IlluminateRequest; use Symfony\Component\HttpFoundation\BinaryFileResponse; use Symfony\Component\HttpFoundation\Response as SymfonyResponse; -use Symfony\Component\HttpFoundation\StreamedResponse; class Laravel { @@ -144,10 +143,7 @@ public function handleDynamic(IlluminateRequest $request) if ($this->isLumen()) { $response = $this->app->dispatch($request); - if ($response instanceof StreamedResponse) { - $content = ''; - $response = $response->sendContent(); - } elseif ($response instanceof SymfonyResponse) { + if ($response instanceof SymfonyResponse) { $content = $response->getContent(); } else { $content = (string)$response; @@ -156,25 +152,13 @@ public function handleDynamic(IlluminateRequest $request) $this->reflectionApp->callTerminableMiddleware($response); } else { $response = $this->kernel->handle($request); - if ($response instanceof StreamedResponse) { - $content = ''; - $response = $response->sendContent(); - } else { - $content = $response->getContent(); - } + $content = $response->getContent(); $this->kernel->terminate($request, $response); } // prefer content in response, secondly ob if (strlen($content) === 0 && ob_get_length() > 0) { - if ($response instanceof StreamedResponse) { - $reflect = new \ReflectionClass(StreamedResponse::class); - $contentProperty = $reflect->getProperty('content'); - $contentProperty->setAccessible(true); - $contentProperty->setValue($response, ob_get_contents()); - } else { - $response->setContent(ob_get_contents()); - } + $response->setContent(ob_get_contents()); } ob_end_clean(); diff --git a/src/Swoole/DynamicResponse.php b/src/Swoole/DynamicResponse.php index 995258e5..079b795b 100644 --- a/src/Swoole/DynamicResponse.php +++ b/src/Swoole/DynamicResponse.php @@ -23,10 +23,9 @@ public function gzip() public function sendContent() { if ($this->laravelResponse instanceof StreamedResponse) { - $reflect = new \ReflectionClass(StreamedResponse::class); - $contentProperty = $reflect->getProperty('content'); - $contentProperty->setAccessible(true); - $content = $contentProperty->getValue($this->laravelResponse); + ob_start(); + $this->laravelResponse = $this->laravelResponse->sendContent(); + $content = ob_get_clean(); } else { $content = $this->laravelResponse->getContent(); }