Skip to content
This repository was archived by the owner on Mar 12, 2025. It is now read-only.

Commit 756c802

Browse files
committed
🐛 添加206的另外一种格式
1 parent 501c648 commit 756c802

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

inc/server.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,12 @@ public function startserver() {
4545
parse_str($request->server['query_string'], $allurl);
4646
if ($this->check_sign($downloadhash, $this->secret, $allurl['s'], $allurl['e'])){
4747
if(isset($request->header['range'])){
48-
preg_match('/bytes=(\d+)-(\d+)/', $request->header['range'], $matches);
49-
$start_byte = (int) $matches[1];
50-
$end_byte = (int) $matches[2];
48+
preg_match('/^bytes=(\d+)(?:-(\d+)?)?$/i', $request->header['range'], $matches);
49+
$start_byte = isset($matches[1]) ? intval($matches[1]) : null;
50+
$end_byte = isset($matches[2]) && $matches[2] !== '' ? intval($matches[2]) : null;
51+
if ($end_byte === '-') {
52+
$end_byte = filesize($this->dir.'/'.substr($downloadhash, 0, 2).'/'.$downloadhash) - 1;
53+
}
5154
$length = $end_byte - $start_byte + 1;
5255
$fileSize = filesize($this->dir.'/'.substr($downloadhash, 0, 2).'/'.$downloadhash);
5356
$code = 206;

0 commit comments

Comments
 (0)