You need to send the Content-Length
with every chunk you send. Look at Wikipedia for a first impression, how a chunked encoding looks like. Its not that trivial and in many cases its oversized.
Update:
First you send the headers, because they must always send before any content (also with chunked encoding). Then you send (for every chunk) the size (in hexadecimal) followed by the content. Remember flush()
after every chunk. At last you must send a zero-size chunk to make sure, that the connection get closed properly.
Its not tested, but something like this
header("Transfer-Encoding: chunked");
echo "5
";
echo "Hello";
echo "
";
flush();
echo "5
";
echo "World";
echo "
";
flush();
echo "0
";
flush();
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…