Skip to content

Instantly share code, notes, and snippets.

@Jimbly
Created November 1, 2012 23:20
Show Gist options
  • Save Jimbly/3997436 to your computer and use it in GitHub Desktop.
Save Jimbly/3997436 to your computer and use it in GitHub Desktop.
Infinite HTTP server
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
var count=0;
function doit() {
while (res.writable && res.write('Data!\r\n\r\n')) {
++count;
if (count % 1000 === 0) {
console.log('wrote ' + count + ' chunks');
return process.nextTick(doit);
}
}
}
res.on('drain', doit);
doit();
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment