【发布时间】:2014-09-14 13:50:23
【问题描述】:
基于以下从 Play 服务器返回分块数据的代码示例,
out.write 不应该在每次调用时都创建响应?
使用 post 客户端时,我只收到 1 个响应,其中包含所有数据的全部数据。
我需要从服务器以块的形式返回一个巨大的文件,该文件应该下载到客户端。 有什么想法吗?
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);
}
【问题讨论】:
标签: java playframework-2.0 chunks