speedtest/backend/garbage.php

32 lines
1,013 B
PHP
Raw Normal View History

2016-03-04 11:48:09 +00:00
<?php
2016-11-28 20:09:12 +00:00
// Disable Compression
@ini_set('zlib.output_compression', 'Off');
@ini_set('output_buffering', 'Off');
@ini_set('output_handler', '');
// Headers
header('HTTP/1.1 200 OK');
if(isset($_GET["cors"])){
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST');
}
// Download follows...
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
2017-09-05 05:45:52 +00:00
header('Content-Disposition: attachment; filename=random.dat');
header('Content-Transfer-Encoding: binary');
// Never cache me
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0, s-maxage=0');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
// Generate data
$data=openssl_random_pseudo_bytes(1048576);
2016-11-28 20:09:12 +00:00
// Deliver chunks of 1048576 bytes
2017-09-05 05:45:52 +00:00
$chunks=isset($_GET['ckSize']) ? intval($_GET['ckSize']) : 4;
if(empty($chunks)){$chunks = 4;}
2019-04-10 05:22:41 +00:00
if($chunks>1024){$chunks = 1024;}
for($i=0;$i<$chunks;$i++){
echo $data;
flush();
2016-03-04 11:48:09 +00:00
}
?>