Node.js HTTP request returns 2 chunks (data bodies)
问题 I'm trying to get the source of an HTML file with an HTTP request in node.js - my problem is that it returns data twice. Here is my code: var req = http.request(options, function(res) { res.setEncoding('utf8'); res.on('data', function (chunk) { if(chunk.length > 1000) { console.log(chunk.length); } }); req.on('error', function(e) { console.log("error" + e.message); }); }); req.end(); This then returns: 5637 3703 The hell! When I just console.log(chunk), it returns all the data as if it were