<?php
$start = intval($_GET["start"]);
$flush = intval($_GET["flush"]);
$prefix = "<p></p>";
$prefix_len = strlen($prefix);
if ($prefix_len > $start) {
    $start = $prefix_len;
} else if ($start > 10000) {
    $start = 10000;
}
$padding_len = $start - $prefix_len;
$padding = str_repeat(" ", $padding_len);
$meta = "<meta charset=windows-1251>";
$end = $start + strlen($meta);
if ($flush < 0) {
    $flush = 0;
} else if ($flush > $end) {
    $flush = 0;
}

header("Content-Type: text/html; charset=bogus");
header("Cache-Control: no-cache");

$buf = $prefix . $padding . $meta;
if ($flush > 0) {
    $head = substr($buf, 0, $flush);
    $tail = substr($buf, $flush);
    echo $head;
    ob_flush(); flush(); ob_flush(); sleep(3);
    echo $tail;
} else {
    echo $buf;
}
?><p>Test: æ</p>
<p>If &#x0436;, meta takes effect</p>
<p>Meta starts within (less-than sign is within) the first <?php echo $start + 1; ?> bytes.</p>
<p>Meta ends within (greater-than sign is within) the first <?php echo $end; ?> bytes.</p>
<p><a href="?start=<?php echo $start - 1 ?>">Previous</a>; <a href="?start=<?php echo $start + 1 ?>">Next</a></p>
