Created
January 12, 2013 12:32
-
-
Save ihower/4517857 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
var spdy = require('spdy'), | |
express = require('express'), | |
fs = require('fs'); | |
var options = { | |
key: fs.readFileSync(__dirname + '/ihower.tw.key'), | |
cert: fs.readFileSync(__dirname + '/ihower.tw.crt'), | |
ca: fs.readFileSync(__dirname + '/ca.pem'), | |
// SPDY-specific options | |
windowSize: 1024, // Server's window size | |
}; | |
var app = express(); | |
app.use(express.static('public')); | |
app.get('/nopush', function(req, res) { | |
res.end('<script src="https://www.ihower.tw:11164/main.js"></script>'); | |
}); | |
app.get('/push', function (req, res) { | |
var headers = { 'content-type': 'application/javascript' }; | |
res.push('/main.js', headers, function(err, stream) { | |
if (err) return; | |
stream.end('alert("hello from push stream!");'); | |
}); | |
res.end('<script src="https://www.ihower.tw:11164/main.js"></script>'); | |
}); | |
var server = spdy.createServer(options, app); | |
server.listen(11164); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment