I googled for this problem but there is no answer for it.
I want my PHP script to generate HTTP response in chunked( http://en.wikipedia.org/wiki/Chunked_transfer_encoding). How to do it?
Update:
I figured it out. I have to specify Transfer-encoding header and flush it.
header("Transfer-encoding: chunked");
flush();
The flush is necessary. Otherwise, Content-Length header will be generated.
And, I have to make chunks by myself. With a helper function, it is not hard.
function dump_chunk($chunk)
{
echo sprintf("%x
", strlen($chunk));
echo $chunk;
echo "
";
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…