播放将分块数据作为一个响应发送

时间:2015-07-01 03:47:05

标签: http playframework

我希望在一个连接中获得多响应,我使用play框架示例代码

def index = Action {
  Ok.chunked(
    Enumerator("kiki", "foo", "bar").andThen(Enumerator.eof)
  )
}

doc显示结果如:

HTTP/1.1 200 OK
Content-Type: text/plain; charset=utf-8
Transfer-Encoding: chunked

4
kiki
3
foo
3
bar
0

但我得到

HTTP/1.1 200 OK
Content-Type: text/plain; charset=utf-8
Request-Time: 1
Transfer-Encoding: chunked
Connection: close
Date: Wed, 01 Jul 2015 03:42:31 GMT

kikifoobar

更新 我使用Paw和chrome 43来测试这个

1 个答案:

答案 0 :(得分:0)

这似乎是Chrome中的一个错误。据报道(或多或少已确认)为issue

注意:当您使用“text / plain”作为内容类型时,似乎只会发生这种情况。您可能需要尝试其他内容类型或添加其他标题:'x-content-type-options':'nosniff',如问题跟踪器中所示。