This is my little piece of code:
var options = {
host: 'www.cuantocabron.com',
port: 80,
path: '/index.php',
method: 'GET'
};
var http = require('http');
var req = http.request(options, function(res) {
console.log('STATUS: ' + res.statusCode);
console.log('HEADERS: ' + JSON.stringify(res.headers));
res.setEncoding('utf8');
res.on('data', function (chunk) {
console.log('BODY: ' + chunk);
});
});
// write data to request body
req.write('data\n');
req.write('data\n');
req.end();
I'm trying to get all the HTML code from that URL; the firts time that I run that code, the console prints all the HTML, but after that, throw an error, so my server goes down.
But, when I run it, the console throw an Error:
events.js:71
throw arguments[i]; //Unhandled 'error' event
Error: Parse Error
at Socket.socketOnData (http.js:1447:20)
at TCP.onread (net.js:404:27)
Any solution? Thanks;