我正在尝试编写两个文件和更多文本来响应。然而,下面的代码只返回第一个文件和“仅此而已!” 文本。
var http = require('http'),
util = require('util'),
fs = require('fs');
server = http.createServer(function(req, res){
var stream = fs.createReadStream('one.html'),
stream2 = fs.createReadStream('two.html');
stream.on('end', function(){
stream2.pipe(res, { end:false});
});
stream2.on('end', function(){
res.end("Thats all!");
});
res.writeHead(200, {'Content-Type' : 'text/plain'});
stream.pipe(res, { end:false});
}).listen(8001);