Skip to content

Commit bd62a68

Browse files
yawntcronopio
authored andcommitted
[fix] now you can pipe()
1 parent c8d9e0f commit bd62a68

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed
+10-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
var Writable = require('stream').Writable,
2+
proxy = require('../../node-http-proxy');
23
http = require('http'),
34
https = require('https'),
45
util = require('util');
@@ -9,7 +10,8 @@ var ForwardStream = module.exports = function ForwardStream(options) {
910
var self = this;
1011

1112
this.once('pipe', function(req) {
12-
self.outgoing = options.https ? https : http;
13+
var protocol = options.https ? https : http,
14+
outgoing = proxy._getBase(options);
1315

1416
[
1517
'host',
@@ -18,7 +20,7 @@ var ForwardStream = module.exports = function ForwardStream(options) {
1820
'socketPath',
1921
'agent'
2022
].forEach(function(elem) {
21-
outgoing[elem] = target[elem];
23+
outgoing[elem] = options[elem];
2224
});
2325

2426
[
@@ -28,16 +30,15 @@ var ForwardStream = module.exports = function ForwardStream(options) {
2830
].forEach(function(elem) {
2931
outgoing[elem] = req[elem];
3032
});
31-
32-
});
33-
34-
}
35-
36-
ForwardStream.prototype._write = function() {
3733

34+
self.request = protocol.request(outgoing)
35+
});
3836

37+
};
3938

40-
}
39+
ForwardStream.prototype._write = function(chunk, encoding, callback) {
40+
this.request.write(chunk, encoding, callback);
41+
};
4142

4243
util.inherits(ForwardStream, Writable);
4344

0 commit comments

Comments
 (0)