Forked from Rush/spdyMultiplePostsPerRequests.js
Last active
January 1, 2016 13:09
-
-
Save Nowaker/8149829 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env node | |
var spdy = require('spdy'), | |
crypto = require('crypto'), | |
fs = require('fs'); | |
b64decode = function(encoded) { | |
return new Buffer(encoded || '', 'base64').toString('utf8'); | |
}; | |
var keys = { | |
"key": b64decode("LS0tLS1CRUdJTiBSU0EgUFJJVkFURSBLRVktLS0tLQpNSUlFcEFJQkFBS0NBUUVBeDRjUTd2YmdNK2JuQXlXVHdWVGl4NXRxUUNWUUxVVFFkMlREdElYZXVZN2lFbVRVCmlEM1hacGhVYlkyQVpJbkwzOHNxRm5iM1ZDVERKbVd2UUZJcHpNNUhSZ2dzOE5tTFRWa1podHV1TWFkMXpGaVEKaExhbUZ0ckdtckRiMGpiMkNrckVYdDFQa29VOThuK0FMVGp2a3A0ZklqbHM4RW1pLyt1em5BL1k1Z1hpdzlUTAp1NXJKYUdWdGpBMXJCK2o1MjZRaEQ3ZHdSTjBuN1lTNHArVDNwczBtTzJPYW9xSE5IZnpMRDFlclFkei92a3ZyCmlQWmp4M1RGZ2U0ZEUxbWN3MmpZMENkcWhDQnBneDJSRExyMTZwZmVRRkNza3p0aGl0d0o5ejlib3UwTTdURksKdnpzQVBEdktwWW5nSkhhdVlBZmlDV0Y0bWMyYVo0MzdJQTBzRFFJREFRQUJBb0lCQUhNRmRjbU1IK3RMck5pdgpqT0hpb1drWU9zUUh2cFNhR3VMNC82ak5rM3U4MXE1cjJlbEFYVEFUbUhnZkhtalcxdVNJSmhjVk5iY1lDamZVClhwYmh4cDcrT3pBdi9saEowSGdpYVFqSkV6NGtuMC9Scmw0VFBPUG44cDJ5WHNac1VLSFdRQ1cveHVOY1ZEMjcKS3BUblFaUnYrdHFyNkJVTkhoNFNMbFJFL25CNjUyM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pIYXVZQWZpQ1dGNG1jMmFaNDM3SUEwc0RRSURBUUFCbzFBd1RqQWRCZ05WSFE0RUZnUVVBZloraTJ2ZApQMXJVQkxmU1B5eFRCWld5Qktvd0h3WURWUjBqQkJnd0ZvQVVBZloraTJ2ZFAxclVCTGZTUHl4VEJaV3lCS293CkRBWURWUjBUQkFVd0F3RUIvekFOQmdrcWhraUc5dzBCQVFVRkFBT0NBUUVBb1VETnRhQUhBSlZYaEhDRVl1UXEKQ1MwOFJwekZQeEZ3QnZhUHNTeWhkZ0lscjJHdzVjb213K1ZCclpZTWxPSnhlY1d6TlFaMXhoNFBySnhiSzhoYQpjR3owb3prMjM0NUpvUXQzVldCYWhZV0ZPYkNxR3QxakI5REpySnQ5c1h4ZDhqKzZIUnFpNE1FenJpSmM2WUY1ClRSUmV5NGpZeTB6K0h3a1FRbndhRFVBbzdNSkF5ZG5RZk91eW9TM3ZPVlpyTkR3dEd0M3ZoaS9oYldKMXNMZEEKNEcyUytjM0o2dVM5RlNtbXhiajExWnZ3REZYU0ZIN0RWMXpkQXFGaFVKOGp4K0FOeENEK01MbmdpSWczUVBldgpkOEVnc1hJV01DSGxwL1ZCbEpUS2FPZk5uWkdXQVpUMDNEOEFIWGpHYUVsWWVqTWRBcitVTEJHOFlObVRUL0x6ClJ3PT0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=") | |
}; | |
var config = { | |
ssl: keys, | |
}; | |
var config2 = { | |
ssl: keys2, | |
}; | |
config.ssl.SNICallback = function(hostname, cb) { | |
if (cb) // 0.11.5 and later | |
return cb(null, loadedKeys); | |
return loadedKeys; // 0.11.4 and earlier; | |
}; | |
var http = require('http'), https = require('https'); | |
var x = "1234567890";for (var i = 0; i < 12; i++) { x += x+x;} | |
var assert = require('assert'); | |
var requestHandler = function(req, res) { | |
var text = "Request method is: " + req.method; | |
console.log(text); | |
res.write(text); | |
res.end(); | |
}; | |
// it's funny - even though SNI prevents SPDY from running, the requests turn our garbled | |
// if run through spdy.createServer | |
var spdyServer = spdy.createServer(config.ssl,requestHandler).listen(40443); | |
var httpsServer = https.createServer(config2.ssl,requestHandler).listen(40444); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment