0) { $chunk = min($chunkSize, $remaining); echo random_bytes($chunk); $remaining -= $chunk; // 立即刷新输出缓冲区 if (ob_get_level()) { ob_flush(); } flush(); } exit; } // 上传测速 if (isset($_GET['action']) && $_GET['action'] == 'upload' && $_SERVER['REQUEST_METHOD'] == 'POST') { // 直接读取并丢弃上传的数据,不保存到服务器 $input = fopen('php://input', 'r'); $total = 0; while ($data = fread($input, 8192)) { $total += strlen($data); } fclose($input); // 返回成功响应 echo 'OK'; exit; } // 如果没有匹配的操作,返回404 http_response_code(404); echo 'Not Found'; ?>