Skip to content

Instantly share code, notes, and snippets.

@suissa
Created October 2, 2014 08:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save suissa/189ccb95653a6934c2e2 to your computer and use it in GitHub Desktop.
Save suissa/189ccb95653a6934c2e2 to your computer and use it in GitHub Desktop.
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