Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 148 | Ganze Datei anzeigen | Leerzeichen ignorieren | Details | Blame | Letzte Änderung | Log anzeigen | RSS feed

Revision 148 Revision 1663
Zeile 32... Zeile 32...
32
     */
32
     */
33
    protected $file;
33
    protected $file;
34
    protected $offset = 0;
34
    protected $offset = 0;
35
    protected $maxlen = -1;
35
    protected $maxlen = -1;
36
    protected $deleteFileAfterSend = false;
36
    protected $deleteFileAfterSend = false;
37
    protected $chunkSize = 8 * 1024;
37
    protected $chunkSize = 16 * 1024;
Zeile 38... Zeile 38...
38
 
38
 
39
    /**
39
    /**
40
     * @param \SplFileInfo|string $file               The file to stream
40
     * @param \SplFileInfo|string $file               The file to stream
41
     * @param int                 $status             The response status code (200 "OK" by default)
41
     * @param int                 $status             The response status code (200 "OK" by default)
Zeile 238... Zeile 238...
238
            // Process the range headers.
238
            // Process the range headers.
239
            if (!$request->headers->has('If-Range') || $this->hasValidIfRangeHeader($request->headers->get('If-Range'))) {
239
            if (!$request->headers->has('If-Range') || $this->hasValidIfRangeHeader($request->headers->get('If-Range'))) {
240
                $range = $request->headers->get('Range');
240
                $range = $request->headers->get('Range');
Zeile 241... Zeile 241...
241
 
241
 
242
                if (str_starts_with($range, 'bytes=')) {
242
                if (str_starts_with($range, 'bytes=')) {
Zeile 243... Zeile 243...
243
                    [$start, $end] = explode('-', substr($range, 6), 2) + [0];
243
                    [$start, $end] = explode('-', substr($range, 6), 2) + [1 => 0];
Zeile 244... Zeile 244...
244
 
244
 
245
                    $end = ('' === $end) ? $fileSize - 1 : (int) $end;
245
                    $end = ('' === $end) ? $fileSize - 1 : (int) $end;
Zeile 309... Zeile 309...
309
                fseek($file, $this->offset);
309
                fseek($file, $this->offset);
310
            }
310
            }
Zeile 311... Zeile 311...
311
 
311
 
312
            $length = $this->maxlen;
312
            $length = $this->maxlen;
313
            while ($length && !feof($file)) {
313
            while ($length && !feof($file)) {
314
                $read = ($length > $this->chunkSize) ? $this->chunkSize : $length;
-
 
Zeile 315... Zeile 314...
315
                $length -= $read;
314
                $read = $length > $this->chunkSize || 0 > $length ? $this->chunkSize : $length;
316
 
-
 
317
                stream_copy_to_stream($file, $out, $read);
-
 
318
 
315
 
319
                if (connection_aborted()) {
316
                if (false === $data = fread($file, $read)) {
-
 
317
                    break;
-
 
318
                }
-
 
319
                while ('' !== $data) {
-
 
320
                    $read = fwrite($out, $data);
-
 
321
                    if (false === $read || connection_aborted()) {
-
 
322
                        break;
-
 
323
                    }
-
 
324
                    if (0 < $length) {
-
 
325
                        $length -= $read;
-
 
326
                    }
320
                    break;
327
                    $data = substr($data, $read);
Zeile 321... Zeile 328...
321
                }
328
                }
322
            }
329
            }
323
 
330