【发布时间】:2011-04-19 05:42:17
【问题描述】:
我有两台 nodejs http 服务器,一台向另一台请求 tar 文件。它通过浏览器测试工作正常,但我永远无法让第二台服务器正确地将块粘合在一起。我对 fwrite 的尝试与此一样无用
// Receives File
var complete_file = '';
response.on('data', function(chunk){
complete_file += chunk
}).on('end', function(){
fs.writeFile('/tmp/test.tgz', complete_file, 'binary')
});
// Send File
fs.readFile('/tmp/test_send.tgz', function(err, data){
if (err) throw err;
response.writeHead('200', {
'Content-Type' : 'application/x-compressed',
'Content-Length' : data.length
});
response.write(data);
response.end();
});
【问题讨论】:
标签: javascript http node.js