Skip to content

Instantly share code, notes, and snippets.

@Unitech
Created May 14, 2014 15:37
Show Gist options
  • Save Unitech/ac0cb44b8d25a1f48cde to your computer and use it in GitHub Desktop.
Save Unitech/ac0cb44b8d25a1f48cde to your computer and use it in GitHub Desktop.
Steam transformer
function createParser () {
var parser = new Transform();
parser._transform = function(data, encoding, done) {
console.log(data);
this.push(data);
done();
};
return parser;
}
http.createServer(function (req, resp) {
var dest = 'http://stackoverflow.com/';
var x = request({url:dest, encoding:null})
x.pipe(createParser()).pipe(resp)
}).listen(8000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment