diff --git a/lib/caronte/streams/forward.js b/lib/caronte/streams/forward.js index b7e8ccd03..f1f85c7e5 100644 --- a/lib/caronte/streams/forward.js +++ b/lib/caronte/streams/forward.js @@ -25,7 +25,7 @@ function ForwardStream() { Writable.call(this); - this.once('pipe', function() { self.onPipe() }); + this.once('pipe', function(pipe) { self.onPipe(pipe) }); this.once('finish', function() { self.onFinish() }); } diff --git a/lib/caronte/streams/proxy.js b/lib/caronte/streams/proxy.js index 8d1f0672f..713550c84 100644 --- a/lib/caronte/streams/proxy.js +++ b/lib/caronte/streams/proxy.js @@ -1,3 +1,40 @@ +var Duplex = require('stream').Duplex, + common = require('../common'), + http = require('http'), + https = require('https'); + function ProxyStream() { + var self = this; + + Duplex.call(this); + + this.once('pipe', function(pipe) { self.onPipe(pipe); }); + this.once('finish', function() { self.onFinish(); }); +} + +ProxyStream.prototype.onPipe = function(request) { + var self = this; + + this.proxyReq = (options.ssl ? https : http).request( + common.setupOutgoing(options.ssl || {}, options, request) + ); + + this.proxyReq.once('response', function(response) { + self.onResponse(response); + }) + this.proxyReq.on('error', function() {}); // XXX TODO: add error handling +} + +ProxyStream.prototype.onFinish = function() { -} \ No newline at end of file +} + +ProxyStream.prototype.onResponse = function() { + +} + +ProxyStream.prototype._read = function() {} + +ProxyStream.prototype._write = function() {} + +require('util').inherits(ForwardStream, Duplex); \ No newline at end of file