Created
January 30, 2015 02:09
-
-
Save yakovkhalinsky/c5c8ee6dff719592d62c to your computer and use it in GitHub Desktop.
Node Fake Response Server with HTTPS
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 https = require('https'); | |
var fs = require('fs'); | |
var sslOptions = { | |
key: fs.readFileSync('localhost.key'), | |
cert: fs.readFileSync('localhost.crt') | |
}; | |
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"; | |
var code = process.env.CODE || 200; | |
var timeout = process.env.TIMEOUT || 0; | |
https.createServer(sslOptions ,function (req, res) { | |
res.writeHead(code, {'Content-Type': 'text/html', 'Access-Control-Allow-Origin': '*'}); | |
setTimeout(function() { | |
res.end('BAM!'); | |
}, timeout); | |
}).listen(10000, function() { | |
console.log('Server running'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment