Mag*_*ero 8 stream http-1.1 node.js
当我尝试利用http流连接由于某种原因写入不会刷新,直到我调用response.end()
我直接从演示中获取代码,并不明白我的问题是什么.
当我卷曲到服务器时,我的标题是正确的.
HTTP/1.1 200 OK
Content-Type: text/plain
Connection: keep-alive
Transfer-Encoding: chunked
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.write('hello');
res.write(':');
setTimeout(function(){
res.end('World\n')},
2000);
}).listen(1337, "127.0.0.1");
console.log('Server running at http://127.0.0.1:1337/');
Run Code Online (Sandbox Code Playgroud)
为什么服务器不发送写入数据?
我似乎是浏览器特定的行为 - firefox立即显示数据("Hello:"),而chrome似乎缓冲并等待响应结束.请注意,如果您首先编写更多数据,Chrome也会立即显示数据(例如,我写了1000个"Hello").
| 归档时间: |
|
| 查看次数: |
23949 次 |
| 最近记录: |