Skip to content

Instantly share code, notes, and snippets.

@brettkiefer
Created February 25, 2011 16:55
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 brettkiefer/844080 to your computer and use it in GitHub Desktop.
Save brettkiefer/844080 to your computer and use it in GitHub Desktop.
Running this (sudo if you want port 443) with node v0.4.1 and hard-refreshing the page several times causes a request to hang
// Assumes a privatekey.pem and certificate.pem in this directory
// Probably have to run as root to start on port 443
var https = require('https');
var fs = require('fs');
var url = require('url');
var server = https.createServer({
key: fs.readFileSync(__dirname + '/privatekey.pem')
, cert: fs.readFileSync(__dirname + '/certificate.pem')
}, function(req, res){
var path = url.parse(req.url).pathname;
switch (path){
case '/':
res.writeHead(200, {'Content-Type': 'text/html'});
res.write('<!doctype html><html><head><title>ssl hanger</title></head><body><h1>Just keep hard-refreshing the page (ctrl-shift-r) and waiting for the page load. Eventually a page will hang.</h1></body></html>');
res.end();
break;
default:
res.writeHead(404);
res.write('404');
res.end();
}
});
server.listen(443);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment