I\'m using node.js to download a webpage. However, it\'s not receiving any chunks of data:
console.log(\'preparing request to \' + url)
u = require(\'url
This is an example which always worked for me:
var sys = require('sys'),
http = require('http');
var connection = http.createClient(8080, 'localhost'),
request = connection.request('/');
connection.addListener('error', function(connectionException){
sys.log(connectionException);
});
request.addListener('response', function(response){
var data = '';
response.addListener('data', function(chunk){
data += chunk;
});
response.addListener('end', function(){
// Do something with data.
});
});
request.end();