[HttpFoundation] Fixed byte ranges in the BinaryFileResponse.

According to rfc2616 (http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35.1)
byte positions are inclusive:

The first-byte-pos value in a byte-range-spec gives the byte-offset of
the first byte in a range. The last-byte-pos value gives the byte-offset
of the last byte in the range; that is, the byte positions specified are
inclusive. Byte offsets start at zero.
This commit is contained in:
Jakub Zalas 2013-02-09 16:02:08 +01:00
parent 63bfd9ef79
commit d9b91458f1
2 changed files with 2 additions and 2 deletions

View File

@ -199,7 +199,7 @@ class BinaryFileResponse extends Response
list($start, $end) = array_map('intval', explode('-', substr($range, 6), 2)) + array(0);
if ('' !== $end) {
$this->maxlen = $end - $start;
$this->maxlen = $end - $start + 1;
} else {
$end = $this->file->getSize() - 1;
}

View File

@ -61,7 +61,7 @@ class BinaryFileResponseTest extends \PHPUnit_Framework_TestCase
$request->headers->set('If-Range', $etag);
$request->headers->set('Range', 'bytes=1-4');
$this->expectOutputString('IF8');
$this->expectOutputString('IF87');
$response = clone $response;
$response->prepare($request);
$response->sendContent();