src/Response.php
protected function _calculateByteRange($size)
    {
        $start = 0;
        $end = $size - 1;

        if ($range = $this->_parseByteRange())
        {
            // HTTP_RANGE中读取数据
            $start = Arr::get($range, 1, $start);

            if ('-' === Arr::get($range, 0))
            {
                // 负数表示返回从后面开始算起的字节数
                $start = $size - abs($start);
            }

            $end = Arr::get($range, 2, $end);
        }

        // 格式化数值，保证在范围内
        $start = abs(intval($start));
        $end = min(abs(intval($end)), $size - 1);
        $start = ($end < $start) ? 0 : max($start, 0);

        return [
            $start,
            $end,
        ];
    }
protected function _calculateByteRange($size)
    {
        $start = 0;
        $end = $size - 1;

        if ($range = $this->_parseByteRange())
        {
            // HTTP_RANGE中读取数据
            $start = Arr::get($range, 1, $start);

            if ('-' === Arr::get($range, 0))
            {
                // 负数表示返回从后面开始算起的字节数
                $start = $size - abs($start);
            }

            $end = Arr::get($range, 2, $end);
        }

        // 格式化数值，保证在范围内
        $start = abs(intval($start));
        $end = min(abs(intval($end)), $size - 1);
        $start = ($end < $start) ? 0 : max($start, 0);

        return [
            $start,
            $end,
        ];
    }
计算要发送的字节范围

@param  int $size
@return array