Created
May 2, 2012 09:33
-
-
Save koichik/2575536 to your computer and use it in GitHub Desktop.
reproduce @lorenwest of #2997
This file contains 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 net = require('net'); | |
var http = require('http'); | |
var server = net.createServer(function(socket) { | |
socket.write('HTTP/1.1 204 No Content\r\n\r\nNo Content'); | |
}).listen(3000, function() { | |
var req = http.get({port: 3000}, function(res) { | |
console.log('got response', res.statusCode); | |
res.on('end', function() { | |
console.log('end response'); | |
}); | |
res.on('error', function(err) { | |
console.log('could not catch here, because this response is ended', err); | |
}); | |
}); | |
req.on('error', function(err) { | |
console.log('could not catch here, because this request is ended', err); | |
}); | |
}); | |
process.on('uncaughtException', function(err) { | |
console.log('we can catch error here', err); | |
server.close(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment