如何通过HTTP传输大量数据?

How to transfer large amount of data through HTTP?

我正在编写一个 Web 服务器,以便能够将大量数据流式传输回客户端。问题是发送数据可能太大了。所以我不知道内容的长度。

也许 chunked HTTP-response 会有所帮助。但是我怎样才能让 HTTP-client 知道数据已经结束 (end of stream)?

RFC 2616第 3.6.1 节中有描述:

The chunked encoding is ended by any chunk whose size is zero, followed by the trailer, which is terminated by an empty line.