Created
May 8, 2012 22:46
-
-
Save piscisaureus/2640099 to your computer and use it in GitHub Desktop.
parse-error.js
This file contains hidden or 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'), | |
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