NOW MANAGED ON CODEBERG
Attachments: Fixed full range request handling
Dan Browne9f906ce5682
diff --git a/app/Http/RangeSupportedStream.php b/app/Http/RangeSupportedStream.phpindex 300f4488c..fce1e9acc 100644--- a/app/Http/RangeSupportedStream.php+++ b/app/Http/RangeSupportedStream.php@@ -92,7 +92,7 @@ class RangeSupportedStreamif ($start < 0 || $start > $end) {$this->responseStatus = 416;$this->responseHeaders['Content-Range'] = sprintf('bytes */%s', $this->fileSize);- } elseif ($end - $start < $this->fileSize - 1) {+ } else {$this->responseLength = $end < $this->fileSize ? $end - $start + 1 : -1;$this->responseOffset = $start;$this->responseStatus = 206;diff --git a/tests/Uploads/AttachmentTest.php b/tests/Uploads/AttachmentTest.phpindex 2e1a7b339..de448d93a 100644--- a/tests/Uploads/AttachmentTest.php+++ b/tests/Uploads/AttachmentTest.php@@ -404,8 +404,8 @@ class AttachmentTest extends TestCase$resp = $this->get($attachment->getUrl($isInline), ['Range' => 'bytes=0-2010']);$resp->assertStreamedContent($content);$resp->assertHeader('Content-Length', '2005');- $resp->assertHeaderMissing('Content-Range');- $resp->assertStatus(200);+ $resp->assertHeader('Content-Range', 'bytes 0-2004/2005');+ $resp->assertStatus(206);// Range start before end$resp = $this->get($attachment->getUrl($isInline), ['Range' => 'bytes=50-10']);@@ -413,6 +413,13 @@ class AttachmentTest extends TestCase$resp->assertHeader('Content-Length', '2005');$resp->assertHeader('Content-Range', 'bytes */2005');$resp->assertStatus(416);++ // Full range request+ $resp = $this->get($attachment->getUrl($isInline), ['Range' => 'bytes=0-']);+ $resp->assertStreamedContent($content);+ $resp->assertHeader('Content-Length', '2005');+ $resp->assertHeader('Content-Range', 'bytes 0-2004/2005');+ $resp->assertStatus(206);}$this->files->deleteAllAttachmentFiles();