当我出于某种原因尝试使用 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/');
为什么服务器不发送写入数据?