Skip to content

Instantly share code, notes, and snippets.

@heapwolf heapwolf/46.js
Created Aug 7, 2012

Embed
What would you like to do?
http/close
var server = require('http').createServer();
var closed = false;
server.on('request', function(req, res) {
if (! closed) {
res.end('Shutting down');
server.close();
closed = true;
} else {
res.end();
}
});
server.listen(4000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.