mirror of
https://github.com/http-party/node-http-proxy.git
synced 2025-12-08 20:59:18 +00:00
[api] add draft for proxystream
This commit is contained in:
parent
cedc5c4bd2
commit
4f24664e8a
@ -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() });
|
||||
}
|
||||
|
||||
|
||||
@ -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);
|
||||
Loading…
x
Reference in New Issue
Block a user