Chrome不会渲染分块的json响应

我想做一个stream式端点,不断发送一个json对象。 我曾尝试使用块传输编码,并能成功地使所有的浏览器(铬,火狐,Safari)呈现从服务器发送的数据,如果是文本/ HTML或文本/纯文本。 但是,当我使用application / json作为内容types时,它在chrome上不起作用。 代码如下:

var http = require('http'); http.createServer(function(request, response){ response.setHeader('Connection', 'Transfer-Encoding'); response.setHeader('Transfer-Encoding', 'chunked'); response.setHeader('Cache-Control', 'no-cache'); // response.setHeader('Content-Type', 'application/json'); response.setHeader('Content-Type', 'text/html'); setInterval(function(){ response.write('test </br>'); // response.write('{"test": "test"}'); }, 10); }).listen(8000); 

上面的代码正常工作,但不能使它与应用程序/ jsontypes。 我错过了什么吗?

这是浏览器中的一个错误。 并固定在最新的铬(至less在金丝雀)。

Chrome Bug – 传输编码分块不支持文本/纯文本

Safari(我已经在Mac OSX上testing过)是唯一没有使用分块编码来呈现非html内容的浏览器。