From 6a4294cbdfe85fa162969b1393032adc9d418441 Mon Sep 17 00:00:00 2001 From: yawnt Date: Fri, 9 Aug 2013 19:40:40 +0200 Subject: [PATCH] [feature] implement _write and _read --- lib/caronte/streams/proxy.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/caronte/streams/proxy.js b/lib/caronte/streams/proxy.js index 713550c..c6b75c4 100644 --- a/lib/caronte/streams/proxy.js +++ b/lib/caronte/streams/proxy.js @@ -29,12 +29,18 @@ ProxyStream.prototype.onFinish = function() { } -ProxyStream.prototype.onResponse = function() { - +ProxyStream.prototype.onResponse = function(proxyRes) { + this.proxyRes = proxyRes; } -ProxyStream.prototype._read = function() {} +ProxyStream.prototype._write = function(chunk, encoding, callback) { + this.proxyReq.write(chunk, encoding, callback); +}; -ProxyStream.prototype._write = function() {} +ProxyStream.prototype._read = function(size) { + var chunk = (this.proxyRes ? this.proxyRes.read(size) : '') || ''; + + this.push(chunk); +}; require('util').inherits(ForwardStream, Duplex); \ No newline at end of file