public function test_find_range_request() { // Missing 'bytes=' prefix $GLOBALS['request'] = new phpbb_mock_request(); $GLOBALS['request']->set_header('Range', 'bztes='); $this->assertEquals(false, phpbb_find_range_request()); unset($GLOBALS['request']); $GLOBALS['request'] = new phpbb_mock_request(); $_ENV['HTTP_RANGE'] = 'bztes='; $this->assertEquals(false, phpbb_find_range_request()); unset($_ENV['HTTP_RANGE']); $GLOBALS['request'] = new phpbb_mock_request(); $GLOBALS['request']->set_header('Range', 'bytes=0-0,123-125'); $this->assertEquals(array('0-0', '123-125'), phpbb_find_range_request()); unset($GLOBALS['request']); }
/** * HTTP range support (RFC 2616 Section 14.35) * * Allows browsers to request partial file content * in case a download has been interrupted. * * @param int $filesize the size of the file in bytes we are about to deliver * * @return mixed false if the whole file has to be delivered * associative array on success */ function phpbb_http_byte_range($filesize) { // Only call find_range_request() once. static $request_array; if (!$filesize) { return false; } if (!isset($request_array)) { $request_array = phpbb_find_range_request(); } return empty($request_array) ? false : phpbb_parse_range_request($request_array, $filesize); }