Skip to content

Commit 6f50a1c

Browse files
committed
Handle Symfony StreamedResponse
1 parent 7c20ef2 commit 6f50a1c

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

Bridges/HttpKernel.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Stack\Builder;
1111
use Symfony\Component\HttpFoundation\Request as SymfonyRequest;
1212
use Symfony\Component\HttpFoundation\Response as SymfonyResponse;
13+
use Symfony\Component\HttpFoundation\StreamedResponse as SymfonyStreamedResponse;
1314

1415
class HttpKernel implements BridgeInterface
1516
{
@@ -36,10 +37,10 @@ class HttpKernel implements BridgeInterface
3637
*/
3738
public function bootstrap($appBootstrap, $appenv)
3839
{
39-
// include applications autoload
40+
// include applications autoload
4041
$autoloader = dirname(realpath($_SERVER['SCRIPT_NAME'])) . '/vendor/autoload.php';
4142
if (file_exists($autoloader)) {
42-
require_once $autoloader;
43+
require_once $autoloader;
4344
}
4445

4546
if (false === class_exists($appBootstrap)) {
@@ -145,6 +146,18 @@ protected static function mapResponse(ReactResponse $reactResponse,
145146
{
146147
$headers = $syResponse->headers->all();
147148
$reactResponse->writeHead($syResponse->getStatusCode(), $headers);
148-
$reactResponse->end($syResponse->getContent());
149+
150+
// @TODO convert StreamedResponse in an async manner
151+
if ($syResponse instanceof SymfonyStreamedResponse) {
152+
ob_start();
153+
$syResponse->sendContent();
154+
$content = ob_get_contents();
155+
ob_end_clean();
156+
}
157+
else {
158+
$content = $syResponse->getContent();
159+
}
160+
161+
$reactResponse->end($content);
149162
}
150163
}

0 commit comments

Comments
 (0)