That was actually easy, problem was with apache and php-fpm, make sure you have flushpackets=auto in your virtualhost conf
Code:
<FilesMatch \.php$>
SetHandler proxy:fcgi://localhost:9000
# for Unix sockets, Apache 2.4.10 or higher
# SetHandler proxy:unix:/path/to/fpm.sock|fcgi://dummy
</FilesMatch>
<Proxy "fcgi://localhost:9000" flushpackets=auto flushwait=10>
</Proxy>
-----
example controller
-----
PHP Code:
public function test(){
$this->session->regenerate(true); // test cookies are sent
$i = 0;
$this->response->setHeader('header-forced','1'); //example add header
$this->response->setBody(''); // clear body
$this->response->send(); // sends headers and cookies
$this->session->close(); //session_write_close()
//long running task
do{
echo $i++.'<br>'.PHP_EOL;
usleep(50000);
ob_end_flush();
if(ob_get_level() > 0) {
@ob_flush();
}
flush();
ob_start();
}while($i < 20);
}