Permalink
Browse files

[fix] fixed that f..reaking bug

  • Loading branch information...
yawnt committed Jul 25, 2013
1 parent 4a6da2c commit 9fa91b4829b7052f61e0146dd6c71909a552c3d1
Showing with 13 additions and 5 deletions.
  1. BIN lib/node-http-proxy/.http-proxy.js.swp
  2. +13 −5 lib/node-http-proxy/streams/proxy.js
Binary file not shown.
@@ -11,8 +11,6 @@ var ProxyStream = module.exports = function ProxyStream(response, options) {
var self = this,
target = options.target,
source = options.source;

self.origRes = response;

this.once('pipe', function(req) {
var protocol = target.https ? https : http,
@@ -25,10 +23,11 @@ var ProxyStream = module.exports = function ProxyStream(response, options) {
}

self.request = protocol.request(outgoing);
self.request.end();
self.on('finish', function() {
self.request.end();
});

self.request.on('response', function (res) {
console.log('yarr yarr');
self.response = res;
if(req.httpVersion === '1.0') {
res.headers.connection = req.headers.connection || 'close';
@@ -62,6 +61,15 @@ var ProxyStream = module.exports = function ProxyStream(response, options) {
response.setHeader(key, res.headers[key]);
});
response.writeHead(response.statusCode);

res.on('readable', function() {
self.read(0);
});

res.on('end', function() {
self.push(null);
});
self.emit('readable');
});


@@ -128,6 +136,6 @@ ProxyStream.prototype._write = function(chunk, encoding, callback) {

ProxyStream.prototype._read = function(size) {
var chunk = this.response ? this.response.read(size) : '';
console.log(chunk.toString());
if(chunk == null) { chunk = '' }
this.push(chunk);
};

3 comments on commit 9fa91b4

@cronopio

This comment has been minimized.

Copy link
Contributor

cronopio replied Jul 26, 2013

@yawnt Thank you man, with this commit most of basic http tests now pass, but Im having troubles in forward case, when use the forward stream. I think that is incomplete by now, I think you are focusing first on this stream, now the question is this stuff kind of finished? can I try to mess with the forward stream adding this new listeners, etc?? I'll be online at IRC to further discuss.

@cronopio

This comment has been minimized.

Copy link
Contributor

cronopio replied Jul 26, 2013

in other words, we can hack together to finish this and the forward stream. :-)

@yawnt

This comment has been minimized.

Copy link
Contributor Author

yawnt replied Jul 26, 2013

ya i focused on proxystream first.. im at the sea right now, so connection sucks .. when will you be online? so we can catch up

Please sign in to comment.