I am streaming an xml file in, using fs.createWriteStream. For whatever reason, if the chunk coming in happens to break up xml closing tag, I am seeing a bunch of null characters being added to the data at the end of the chunk and it breaks the xml.
This may be caused since we have to replace all the xml reserved values(<,>, 
, etc) with the proper characters(<,>, etc.) after we stream the data file in. Any ideas on why this occurs and how to properly handle it? Here's the basic stream code:
var writableStream = fs.createWriteStream(file_path + send_id + '.xml', { highWaterMark: 128 * 1024 });
var options = {
host: domain_name,
path: f_path,
method: 'POST',
'Content-Type': 'text/html',
'Content-Length':Buffer.byteLength(send_id)
};
var req = http.request(options, (res) =>{
res.setEncoding('utf8');
res.on('data', (chunk) => {
writableStream.write(chunk);
});
res.on('end', () => {
console.log('No more data in response');
});
});
req.write(send_id);
req.end();