protected function getHttpRange($fileSize)
    {
        $rangeHeader = Yii::$app->getRequest()->getHeaders()->get('Range', '-');
        if ($rangeHeader === '-') {
            return [0, $fileSize - 1];
        }
        if (!preg_match('/^bytes=(\d*)-(\d*)$/', $rangeHeader, $matches)) {
            return false;
        }
        if ($matches[1] === '') {
            $start = $fileSize - $matches[2];
            $end = $fileSize - 1;
        } elseif ($matches[2] !== '') {
            $start = $matches[1];
            $end = $matches[2];
            if ($end >= $fileSize) {
                $end = $fileSize - 1;
            }
        } else {
            $start = $matches[1];
            $end = $fileSize - 1;
        }
        if ($start < 0 || $start > $end) {
            return false;
        }

        return [$start, $end];
    }
protected function getHttpRange($fileSize)
    {
        $rangeHeader = Yii::$app->getRequest()->getHeaders()->get('Range', '-');
        if ($rangeHeader === '-') {
            return [0, $fileSize - 1];
        }
        if (!preg_match('/^bytes=(\d*)-(\d*)$/', $rangeHeader, $matches)) {
            return false;
        }
        if ($matches[1] === '') {
            $start = $fileSize - $matches[2];
            $end = $fileSize - 1;
        } elseif ($matches[2] !== '') {
            $start = $matches[1];
            $end = $matches[2];
            if ($end >= $fileSize) {
                $end = $fileSize - 1;
            }
        } else {
            $start = $matches[1];
            $end = $fileSize - 1;
        }
        if ($start < 0 || $start > $end) {
            return false;
        }

        return [$start, $end];
    }
protected function getHttpRange ( $ fileSize ) { $ rangeHeader = Yii :: $ app -> getRequest ( ) -> getHeaders ( ) -> get ( 'Range' , '-' ) ; if ( $ rangeHeader === '-' ) { return [ 0 , $ fileSize - 1 ] ; } if ( ! preg_match ( '/^bytes=(\d*)-(\d*)$/' , $ rangeHeader , $ matches ) ) { return false ; } if ( $ matches [ 1 ] === '' ) { $ start = $ fileSize - $ matches [ 2 ] ; $ end = $ fileSize - 1 ; } elseif ( $ matches [ 2 ] !== '' ) { $ start = $ matches [ 1 ] ; $ end = $ matches [ 2 ] ; if ( $ end >= $ fileSize ) { $ end = $ fileSize - 1 ; } } else { $ start = $ matches [ 1 ] ; $ end = $ fileSize - 1 ; } if ( $ start < 0 || $ start > $ end ) { return false ; } return [ $ start , $ end ] ; }
Determines the HTTP range given in the request.
@param int $fileSize the size of the file that will be used to validate the requested HTTP range.
@return array|bool the range (begin, end), or false if the range request is invalid.
Determines the HTTP range given in the request .