Created
June 29, 2015 18:28
-
-
Save m0ppers/ae20ccec50326f4b6a0d to your computer and use it in GitHub Desktop.
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 http = require("http"); | |
var net = require("net"); | |
var installErrorHandling = function(agent) { | |
agent.createConnection = function(options) { | |
var socket = net.createConnection(options); | |
socket.on("error", function(error) { | |
console.log("GOT ERROR", error, "request options:", options); | |
}); | |
return socket; | |
}; | |
} | |
installErrorHandling(http.globalAgent); | |
var options = { | |
hostname: 'localhost', | |
port: 87, | |
path: '/neineineine' | |
}; | |
http.request(options, function(res) { | |
console.log("GOT RESPONSE", res); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment