Created
June 9, 2013 10:34
-
-
Save gildean/5743076 to your computer and use it in GitHub Desktop.
WebM streaming from tcp to http
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 net = require('net'); | |
var server = require('http').createServer(app).listen(8000); | |
function app(req, res) { | |
if (req.url === '/') { | |
res.writeHead(200, {'Content-Type': 'video/webm'}); | |
var socket = new net.Socket(); | |
socket.connect(5000, 'localhost').pipe(res); | |
} else { | |
res.statusCode = 404; | |
res.end(); | |
} | |
} |
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 fs = require('fs'); | |
var server = require('net').createServer(function (conn) { | |
fs.createReadStream('./big_buck_bunny.webm').pipe(conn); | |
}).listen(5000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment