Created
May 7, 2013 20:00
-
-
Save danfinlay/5535637 to your computer and use it in GitHub Desktop.
Trying to serve a video stream with low capacity to more users. I haven't really used streams before. This was my best guess, but I'm sure there's some fundamental problem. The error this throws is: "You cannot pipe after data has been emitted from the response."
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 request = require('request') | |
var r = request('http://my-video-stream-url', function(err, response){ | |
if(err){ | |
console.log("Request had error: "+err) | |
}else{ | |
http.createServer(function(request, response) { | |
response.setHeader('Content-Type', 'image/jpeg'); | |
response.setHeader('Accept-Ranges', 'bytes'); | |
r.pipe(response) | |
r.on('end', function(){ | |
response.end() | |
}) | |
}).listen(3021); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment