Created
October 2, 2014 08:44
-
-
Save suissa/189ccb95653a6934c2e2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http'); | |
// Criando o servidor para o proxy | |
http.Server(function(req, res){ | |
res.writeHead(200, { | |
'Content-Type' : 'application/json; charset=utf-8', | |
'Transfer-Encoding' : 'chunked' | |
}); | |
setInterval(function(){ | |
res.write(JSON.stringify({ | |
hello : 'Hello world', date : new Date() | |
}) + '\n'); | |
}, 1000); | |
}).listen(8080); | |
setTimeout(function(){ | |
var client = http.get('http://localhost:8080', function(res){ | |
res.on('data', function(data){ | |
console.log(data.toString()); | |
}); | |
}); | |
}, 3000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment