Content-Length header value is not equal to real content length

607 Views Asked by At

Trying to close connection with browser and keep php process alive, but browser waiting for the process end. I think that the problem is in real content length. There is my code in ZF1:

ob_end_clean();
header("Connection: close");
ignore_user_abort(true);
ob_start();
echo Zend_Controller_Front::getInstance()->getResponse()->getBody();
$size = ob_get_length();
header("Content-Length: $size");
Zend_Session::writeClose();
ob_end_flush();
ob_flush();
flush();

sleep(5); // for example

So browser keeps connection for 5 sec. Variable $size value is equal with content characters count. When trying to print empty content and set $size variable to 0, then browser work as expected and don't wait for 5 seconds. Could you please share your ideas what the problem can be?

0

There are 0 best solutions below