Skip to content

Commit

Permalink
[api] add draft for proxystream
Browse files Browse the repository at this point in the history
  • Loading branch information
yawnt committed Aug 9, 2013
1 parent cedc5c4 commit 4f24664
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/caronte/streams/forward.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() });
}

Expand Down
39 changes: 38 additions & 1 deletion lib/caronte/streams/proxy.js
Original file line number Diff line number Diff line change
@@ -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() {

}
}

ProxyStream.prototype.onResponse = function() {

}

ProxyStream.prototype._read = function() {}

ProxyStream.prototype._write = function() {}

require('util').inherits(ForwardStream, Duplex);

0 comments on commit 4f24664

Please sign in to comment.