src/Bridge/Symfony/HttpFoundation/ResponseProcessor.php
<?php
declare(strict_types=1);
namespace K911\Swoole\Bridge\Symfony\HttpFoundation;
use Swoole\Http\Response as SwooleResponse;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Symfony\Component\HttpFoundation\Response as HttpFoundationResponse;
final class ResponseProcessor implements ResponseProcessorInterface
{
/**
* {@inheritdoc}
*/
public function process(HttpFoundationResponse $httpFoundationResponse, SwooleResponse $swooleResponse): void
{
if ($httpFoundationResponse instanceof BinaryFileResponse) {
$swooleResponse->sendfile($httpFoundationResponse->getFile()->getRealPath());
} else {
$swooleResponse->end($httpFoundationResponse->getContent());
}
}
}