mirror of
https://github.com/appwrite/appwrite
synced 2026-05-24 09:28:40 +00:00
fix range header and test
This commit is contained in:
parent
547302c80c
commit
cc65339a01
3 changed files with 6 additions and 5 deletions
|
|
@ -1069,7 +1069,7 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/download')
|
|||
list($unit, $range) = explode('=', $rangeHeader);
|
||||
if($unit == 'bytes' && !empty($range)) {
|
||||
list($rangeStart, $rangeEnd) = explode('-', $range);
|
||||
if(strlen($rangeStart) == 0) {
|
||||
if(strlen($rangeStart) == 0 || strstr($range, '-') === false) {
|
||||
throw new Exception('Invalid range', 416);
|
||||
}
|
||||
$rangeStart = (int) $rangeStart;
|
||||
|
|
|
|||
|
|
@ -338,6 +338,7 @@ App::error(function ($error, $utopia, $request, $response, $layout, $project) {
|
|||
case 404: // Error allowed publicly
|
||||
case 409: // Error allowed publicly
|
||||
case 412: // Error allowed publicly
|
||||
case 416: // Error allowed publicly
|
||||
case 429: // Error allowed publicly
|
||||
case 501: // Error allowed publicly
|
||||
case 503: // Error allowed publicly
|
||||
|
|
|
|||
|
|
@ -304,8 +304,8 @@ trait StorageBase
|
|||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'Range' => 'bytes=0-',
|
||||
], $this->getHeaders()));
|
||||
|
||||
$this->assertEquals(400, $file52['headers']['status-code']);
|
||||
|
||||
$this->assertEquals(206, $file52['headers']['status-code']);
|
||||
|
||||
// Test ranged download - with invalid range
|
||||
$file53 = $this->client->call(Client::METHOD_GET, '/storage/buckets/' . $bucketId . '/files/' . $data['fileId'] . '/download', array_merge([
|
||||
|
|
@ -314,7 +314,7 @@ trait StorageBase
|
|||
'Range' => 'bytes=988',
|
||||
], $this->getHeaders()));
|
||||
|
||||
$this->assertEquals(400, $file53['headers']['status-code']);
|
||||
$this->assertEquals(416, $file53['headers']['status-code']);
|
||||
|
||||
// Test ranged download - with invalid range
|
||||
$file54 = $this->client->call(Client::METHOD_GET, '/storage/buckets/' . $bucketId . '/files/' . $data['fileId'] . '/download', array_merge([
|
||||
|
|
@ -323,7 +323,7 @@ trait StorageBase
|
|||
'Range' => 'bytes=-988',
|
||||
], $this->getHeaders()));
|
||||
|
||||
$this->assertEquals(400, $file54['headers']['status-code']);
|
||||
$this->assertEquals(416, $file54['headers']['status-code']);
|
||||
|
||||
$file6 = $this->client->call(Client::METHOD_GET, '/storage/buckets/' . $bucketId . '/files/' . $data['fileId'] . '/view', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
|
|
|
|||
Loading…
Reference in a new issue