Created
February 25, 2011 16:55
-
-
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
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
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
// 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