Skip to content

Commit 54329d8

Browse files
committed
[HttpFoundation] Set the Content-Range header if the requested Range is unsatisfied
1 parent fd4edff commit 54329d8

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/Symfony/Component/HttpFoundation/BinaryFileResponse.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ public function prepare(Request $request)
252252
if ($start <= $end) {
253253
if ($start < 0 || $end > $fileSize - 1) {
254254
$this->setStatusCode(416);
255+
$this->headers->set('Content-Range', sprintf('bytes */%s', $fileSize));
255256
} elseif ($start !== 0 || $end !== $fileSize - 1) {
256257
$this->maxlen = $end < $fileSize ? $end - $start + 1 : -1;
257258
$this->offset = $start;

src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ public function testInvalidRequests($requestRange)
211211
$response->sendContent();
212212

213213
$this->assertEquals(416, $response->getStatusCode());
214-
#$this->assertEquals('', $response->headers->get('Content-Range'));
214+
$this->assertEquals('bytes */35', $response->headers->get('Content-Range'));
215215
}
216216

217217
public function provideInvalidRanges()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy