I am trying to get XML as string by calling HTTP GET (REST) from node js. I think the server sends the response only once but node receives it in chunks as it comes to res.on('data') multiple times. As i concatenate the multiple chunks, I get my complete data. But this takes a lot of time. I want to get all the data in one go. Please provide your views. Thanks in advance.
You can't just "get all the data in one go" because that's not how TCP works. So if you're expecting that, then there is going to be some buffering going on at some other layer, whether you're doing it explicitly or not.
If you are going to be parsing the XML you're downloading, then you might look into using an XML parsing module that supports parsing chunks at a time, such as sax.
Otherwise if you want something more user-friendly (but requires the complete buffered XML string), you might look at using cheerio with xmlMode: true.