Cake\Http\ResponseEmitter::emitBodyRange PHP Метод

emitBodyRange() защищенный Метод

Emit a range of the message body.
protected emitBodyRange ( array $range, Psr\Http\Message\ResponseInterface $response, integer $maxBufferLength ) : void
$range array The range data to emit
$response Psr\Http\Message\ResponseInterface The response to emit
$maxBufferLength integer The chunk size to emit
Результат void
    protected function emitBodyRange(array $range, ResponseInterface $response, $maxBufferLength)
    {
        list($unit, $first, $last, $length) = $range;
        $body = $response->getBody();
        if (!$body->isSeekable()) {
            $contents = $body->getContents();
            echo substr($contents, $first, $last - $first + 1);
            return;
        }
        $body = new RelativeStream($body, $first);
        $body->rewind();
        $pos = 0;
        $length = $last - $first + 1;
        while (!$body->eof() && $pos < $length) {
            if ($pos + $maxBufferLength > $length) {
                echo $body->read($length - $pos);
                break;
            }
            echo $body->read($maxBufferLength);
            $pos = $body->tell();
        }
    }