Skip to content

Commit

Permalink
[fix] now you can pipe()
Browse files Browse the repository at this point in the history
  • Loading branch information
yawnt committed Jun 24, 2013
1 parent ac92c65 commit c278fb8
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions lib/node-http-proxy/streams/forward.js
@@ -1,4 +1,5 @@
var Writable = require('stream').Writable,
proxy = require('../../node-http-proxy');
http = require('http'),
https = require('https'),
util = require('util');
Expand All @@ -9,7 +10,8 @@ var ForwardStream = module.exports = function ForwardStream(options) {
var self = this;

this.once('pipe', function(req) {
self.outgoing = options.https ? https : http;
var protocol = options.https ? https : http,
outgoing = proxy._getBase(options);

[
'host',
Expand All @@ -18,7 +20,7 @@ var ForwardStream = module.exports = function ForwardStream(options) {
'socketPath',
'agent'
].forEach(function(elem) {
outgoing[elem] = target[elem];
outgoing[elem] = options[elem];
});

[
Expand All @@ -28,16 +30,15 @@ var ForwardStream = module.exports = function ForwardStream(options) {
].forEach(function(elem) {
outgoing[elem] = req[elem];
});

});

}

ForwardStream.prototype._write = function() {

self.request = protocol.request(outgoing)
});

};

}
ForwardStream.prototype._write = function(chunk, encoding, callback) {
this.request.write(chunk, encoding, callback);
};

util.inherits(ForwardStream, Writable);

0 comments on commit c278fb8

Please sign in to comment.