基于以下从Play服务器返回分块数据的代码示例,out.write不应该在每次调用时都创建响应?当使用post客户端时,我只得到一个包含所有数据的响应。
我需要从服务器返回一个大文件,这些文件应该下载到客户端。有什么想法吗?
public static Result index(){
// Prepare a chunked text stream
Chunks<String> chunks = new StringChunks()
{
// Called when the stream is ready
public void onReady(Chunks.Out<String> out)
{
out.write("kiki");
out.write("foo");
out.write("bar");
out.close();
}
};// Serves this stream with 200 OK
return ok(chunks);
} 发布于 2014-10-05 04:30:06
区块的大小取决于区块大小,在整个框架中,区块大小通常默认为1024 KB。您的输出太小,因此只发送了一个区块。
https://stackoverflow.com/questions/25833955
复制相似问题