for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Hhxsv5\LaravelS\Swoole;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Symfony\Component\HttpFoundation\File\File;
class StaticResponse extends Response
{
/**@var BinaryFileResponse */
protected $laravelResponse;
public function gzip()
}
/**
* @throws \Exception
*/
public function sendContent()
/**@var File $file */
$file = $this->laravelResponse->getFile();
$this->swooleResponse->header('Content-Type', $file->getMimeType());
if ($this->laravelResponse->getStatusCode() == BinaryFileResponse::HTTP_NOT_MODIFIED) {
$this->swooleResponse->end();
} else {
$path = $file->getRealPath();
if (filesize($path) > 0) {
if (version_compare(swoole_version(), '1.7.21', '<')) {
throw new \RuntimeException('sendfile() require Swoole >= 1.7.21');
$this->swooleResponse->sendfile($path);
// Support deleteFileAfterSend: https://github.com/symfony/http-foundation/blob/5.0/BinaryFileResponse.php#L305
$reflection = new \ReflectionObject($this->laravelResponse);
try {
$deleteFileAfterSend = $reflection->getProperty('deleteFileAfterSend');
$deleteFileAfterSend->setAccessible(true);
if ($deleteFileAfterSend->getValue($this->laravelResponse) && file_exists($file->getPathname())) {
unlink($file->getPathname());
} catch (\Exception $e) {