Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"require": {
"php": "^8.0",
"aws/aws-sdk-php": "^3.222",
"bref/bref": "^2.1.8",
"bref/bref": "^2.4.9",
"bref/laravel-health-check": "^1",
"bref/monolog-bridge": "^1.0",
"illuminate/container": "^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0",
Expand Down
17 changes: 16 additions & 1 deletion src/Http/OctaneHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
use Bref\Event\Http\HttpHandler;
use Bref\Event\Http\HttpResponse;
use Bref\Event\Http\HttpRequestEvent;

use Generator;
use ReflectionFunction;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Symfony\Component\HttpFoundation\StreamedResponse;

class OctaneHandler extends HttpHandler
{
Expand Down Expand Up @@ -45,6 +47,19 @@ public function handleRequest(HttpRequestEvent $event, Context $context): HttpRe
$response->prepare($request); // https://github.com/laravel/framework/pull/43895
}

if (
($response instanceof StreamedResponse) &&
($responseCallback = $response->getCallback()) &&
// @phpstan-ignore-next-line
((new ReflectionFunction($responseCallback))->getReturnType()?->getName() === Generator::class)
) {
return new HttpResponse(
$responseCallback(),
$response->headers->all(),
$response->getStatusCode()
);
}

$content = $response instanceof BinaryFileResponse
? $response->getFile()->getContent()
: $response->getContent();
Expand Down