1 | <?php |
||
14 | class ReadResponse |
||
15 | { |
||
16 | use Utils\FileTrait; |
||
17 | |||
18 | private $continueOnError = false; |
||
19 | |||
20 | /** |
||
21 | * Configure if continue to the next middleware if the response has not found |
||
22 | * |
||
23 | * @param bool $continueOnError |
||
24 | * |
||
25 | * @return self |
||
26 | */ |
||
27 | public function continueOnError($continueOnError = true) |
||
33 | |||
34 | /** |
||
35 | * Execute the middleware. |
||
36 | * |
||
37 | * @param ServerRequestInterface $request |
||
38 | * @param ResponseInterface $response |
||
39 | * @param callable $next |
||
40 | * |
||
41 | * @return ResponseInterface |
||
42 | */ |
||
43 | public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next) |
||
84 | |||
85 | /** |
||
86 | * Reads a file and write in the body. |
||
87 | * |
||
88 | * @param string $file |
||
89 | * @param StreamInterface $body |
||
90 | */ |
||
91 | private static function readFile($file, StreamInterface $body) |
||
107 | |||
108 | /** |
||
109 | * Handle range requests. |
||
110 | * |
||
111 | * @param ServerRequestInterface $request |
||
112 | * @param ResponseInterface $response |
||
113 | * |
||
114 | * @return ResponseInterface |
||
115 | */ |
||
116 | private static function range(ServerRequestInterface $request, ResponseInterface $response) |
||
138 | |||
139 | /** |
||
140 | * Parses a range header, for example: bytes=500-999. |
||
141 | * |
||
142 | * @param string $header |
||
143 | * |
||
144 | * @return false|array [first, last] |
||
145 | */ |
||
146 | private static function parseRangeHeader($header) |
||
157 | } |
||
158 |