I have two nodejs http servers, one requests a tar file from the other. It works fine via browser testing, but I can never get the second server to glue the chunks together correctly. My attempts with fwrite has been as useless as this
// 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();
});