Created
July 12, 2012 03:51
-
-
Save max-mapper/3095611 to your computer and use it in GitHub Desktop.
mux-demux over 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 request = require('request') | |
var muxdemux = require('mux-demux') | |
var uri = "http://localhost:8080/listen" | |
var mux = muxdemux() | |
var stream = mux.createWriteStream('listen') | |
var req = request.post({uri: uri, json: true}) | |
mux.pipe(req) | |
stream.write("") |
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 http = require('http') | |
http.createServer(function (req, res) { | |
var demux = muxdemux() | |
req.pipe(demux) | |
demux.on('connection', function(stream) { | |
console.log('stream', stream) | |
}) | |
}).listen(8080) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment