Skip to content

Commit 9d9130c

Browse files
authored
[12.x] Fix resolving StreamResponse callback on Laravel Octane (#56413)
fix laravel/octane#1040 Signed-off-by: Mior Muhammad Zaki <[email protected]>
1 parent 9bc12a3 commit 9d9130c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/Illuminate/Routing/ResponseFactory.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,12 @@ public function eventStream(Closure $callback, array $headers = [], StreamedEven
194194
public function stream($callback, $status = 200, array $headers = [])
195195
{
196196
if (! is_null($callback) && (new ReflectionFunction($callback))->isGenerator()) {
197+
if (isset($_SERVER['LARAVEL_OCTANE'])) {
198+
return (new StreamedResponse(
199+
null, $status, array_merge($headers, ['X-Accel-Buffering' => 'no'])
200+
))->setCallback($callback);
201+
}
202+
197203
return new StreamedResponse(function () use ($callback) {
198204
foreach ($callback() as $chunk) {
199205
echo $chunk;

0 commit comments

Comments
 (0)