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

+1
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

+1-1
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)