Conditions | 4 |
Paths | 4 |
Total Lines | 16 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
20 | public function sendContent() |
||
21 | { |
||
22 | /**@var File $file */ |
||
23 | $file = $this->laravelResponse->getFile(); |
||
24 | $this->swooleResponse->header('Content-Type', $file->getMimeType()); |
||
25 | if ($this->laravelResponse->getStatusCode() == BinaryFileResponse::HTTP_NOT_MODIFIED) { |
||
26 | $this->swooleResponse->end(); |
||
27 | } else { |
||
28 | $path = $file->getRealPath(); |
||
29 | if (filesize($path) > 0) { |
||
30 | if (version_compare(swoole_version(), '1.7.21', '<')) { |
||
31 | throw new \RuntimeException('sendfile() require Swoole >= 1.7.21'); |
||
32 | } |
||
33 | $this->swooleResponse->sendfile($path); |
||
34 | } else { |
||
35 | $this->swooleResponse->end(); |
||
36 | } |
||
39 | } |