From 54329d836c0a63fec3f2b10f8c222cb865187f9d Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Wed, 9 Mar 2016 16:57:57 +0000 Subject: [PATCH] [HttpFoundation] Set the Content-Range header if the requested Range is unsatisfied --- src/Symfony/Component/HttpFoundation/BinaryFileResponse.php | 1 + .../Component/HttpFoundation/Tests/BinaryFileResponseTest.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php b/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php index 490726dadf799..8e2e0f4bb56d6 100644 --- a/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php +++ b/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php @@ -252,6 +252,7 @@ public function prepare(Request $request) if ($start <= $end) { if ($start < 0 || $end > $fileSize - 1) { $this->setStatusCode(416); + $this->headers->set('Content-Range', sprintf('bytes */%s', $fileSize)); } elseif ($start !== 0 || $end !== $fileSize - 1) { $this->maxlen = $end < $fileSize ? $end - $start + 1 : -1; $this->offset = $start; diff --git a/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php index 4c055ff8a17f8..8f6b0e7424c91 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php @@ -211,7 +211,7 @@ public function testInvalidRequests($requestRange) $response->sendContent(); $this->assertEquals(416, $response->getStatusCode()); - #$this->assertEquals('', $response->headers->get('Content-Range')); + $this->assertEquals('bytes */35', $response->headers->get('Content-Range')); } public function provideInvalidRanges() 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