Skip to content

Instantly share code, notes, and snippets.

@piscisaureus
Created May 8, 2012 22:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save piscisaureus/2640099 to your computer and use it in GitHub Desktop.
Save piscisaureus/2640099 to your computer and use it in GitHub Desktop.
parse-error.js
var net = require('net'),
http = require('http');
var brokenServer = net.createServer(function(socket) {
/* Write some broken headers. */
socket.write('SNAFU/0.1 1337 broken response\r\n');
socket.write('Content-Type: fubar\r\n');
socket.write('\r\n');
socket.write('Hello, moon\n');
socket.destroySoon();
socket.on('error', function() {});
});
brokenServer.listen(8000);
var options = {
host: '127.0.0.1',
port: 8000,
path: '/index.html'
};
setInterval(function() {
http.get(options, onResponse, onError);
function onResponse(res) {
console.log("Response:", res);
}
function onError(err) {
console.log("Error:", err);
}
}, 10);
process.on('uncaughtException', function(e) {
console.log("uncaught: ", e)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment