public function getHTTPUpdateRange(RequestInterface $request)
    {
        $range = $request->getHeader('X-Update-Range');
        if (is_null($range)) {
            return null;
        }

        // Matching "Range: bytes=1234-5678: both numbers are optional

        if (!preg_match('/^(append)|(?:bytes=([0-9]+)-([0-9]*))|(?:bytes=(-[0-9]+))$/i', $range, $matches)) {
            return null;
        }

        if ('append' === $matches[1]) {
            return [self::RANGE_APPEND];
        } elseif (strlen($matches[2]) > 0) {
            return [self::RANGE_START, (int) $matches[2], (int) $matches[3] ?: null];
        } else {
            return [self::RANGE_END, (int) $matches[4]];
        }
    }
public function getHTTPUpdateRange(RequestInterface $request)
    {
        $range = $request->getHeader('X-Update-Range');
        if (is_null($range)) {
            return null;
        }

        // Matching "Range: bytes=1234-5678: both numbers are optional

        if (!preg_match('/^(append)|(?:bytes=([0-9]+)-([0-9]*))|(?:bytes=(-[0-9]+))$/i', $range, $matches)) {
            return null;
        }

        if ('append' === $matches[1]) {
            return [self::RANGE_APPEND];
        } elseif (strlen($matches[2]) > 0) {
            return [self::RANGE_START, (int) $matches[2], (int) $matches[3] ?: null];
        } else {
            return [self::RANGE_END, (int) $matches[4]];
        }
    }
public function getHTTPUpdateRange ( RequestInterface $ request ) { $ range = $ request -> getHeader ( 'X-Update-Range' ) ; if ( is_null ( $ range ) ) { return null ; } // Matching "Range: bytes=1234-5678: both numbers are optional if ( ! preg_match ( '/^(append)|(?:bytes=([0-9]+)-([0-9]*))|(?:bytes=(-[0-9]+))$/i' , $ range , $ matches ) ) { return null ; } if ( 'append' === $ matches [ 1 ] ) { return [ self :: RANGE_APPEND ] ; } elseif ( strlen ( $ matches [ 2 ] ) > 0 ) { return [ self :: RANGE_START , ( int ) $ matches [ 2 ] , ( int ) $ matches [ 3 ] ? : null ] ; } else { return [ self :: RANGE_END , ( int ) $ matches [ 4 ] ] ; } }
Returns the HTTP custom range update header.

This method returns null if there is no well-formed HTTP range request
header. It returns array(1) if it was an append request, array(2,
$start, $end) if it's a start and end range, lastly it's array(3,
$endoffset) if the offset was negative, and should be calculated from
the end of the file.

Examples:

null - invalid
[1] - append
[2,10,15] - update bytes 10, 11, 12, 13, 14, 15
[2,10,null] - update bytes 10 until the end of the patch body
[3,-5] - update from 5 bytes from the end of the file.

@param RequestInterface $request

@return array|null
Returns the HTTP custom range update header .