Skip to content

Commit

Permalink
[HttpFoundation] Fixed byte ranges in the BinaryFileResponse.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jakzal committed Feb 9, 2013
1 parent 63bfd9e commit d9b9145
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Expand Up @@ -199,7 +199,7 @@ public function prepare(Request $request)
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;
}
Expand Down
Expand Up @@ -61,7 +61,7 @@ public function testRequests()
$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();
Expand Down

0 comments on commit d9b9145

Please sign in to comment.