根据Chunked transfer encoding - browser behavior
set_time_limit(0);
header('Content-Encoding: chunked');
header('Transfer-Encoding: chunked');
header('Content-Type: text/plain;charset=utf-8');
header('Connection: keep-alive');
echo str_pad('', 1024, ' ');
while (true) {
// do some echo
ob_flush();
flush();
}
大家好,我的代码有问题吗?它不适用于chrome。在卷曲和工作中工作得很好狩猎。
答案 0 :(得分:1)
这有效。
set_time_limit(0);
header('Content-Encoding: chunked');
header('Transfer-Encoding: chunked');
header('Content-Type: text/plain;charset=utf-8');
header('Connection: keep-alive');
while (true) {
echo str_pad('', 1024, ' ');// browser/nginx/fastcgi max buffer size
// do some echo
// ob_flush();
flush();
}