1 | <?php |
||
14 | class ReadResponse |
||
15 | { |
||
16 | use Utils\FileTrait; |
||
17 | |||
18 | /** |
||
19 | * Execute the middleware. |
||
20 | * |
||
21 | * @param ServerRequestInterface $request |
||
22 | * @param ResponseInterface $response |
||
23 | * @param callable $next |
||
24 | * |
||
25 | * @return ResponseInterface |
||
26 | */ |
||
27 | public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next) |
||
63 | |||
64 | /** |
||
65 | * Reads a file and write in the body. |
||
66 | * |
||
67 | * @param string $file |
||
68 | * @param StreamInterface $body |
||
69 | */ |
||
70 | private static function readFile($file, StreamInterface $body) |
||
86 | |||
87 | /** |
||
88 | * Handle range requests. |
||
89 | * |
||
90 | * @param ServerRequestInterface $request |
||
91 | * @param ResponseInterface $response |
||
92 | * |
||
93 | * @return ResponseInterface |
||
94 | */ |
||
95 | private static function range(ServerRequestInterface $request, ResponseInterface $response) |
||
117 | |||
118 | /** |
||
119 | * Parses a range header, for example: bytes=500-999. |
||
120 | * |
||
121 | * @param string $header |
||
122 | * |
||
123 | * @return false|array [first, last] |
||
124 | */ |
||
125 | private static function parseRangeHeader($header) |
||
136 | } |
||
137 |