1
1
var Writable = require ( 'stream' ) . Writable ,
2
+ proxy = require ( '../../node-http-proxy' ) ;
2
3
http = require ( 'http' ) ,
3
4
https = require ( 'https' ) ,
4
5
util = require ( 'util' ) ;
@@ -9,7 +10,8 @@ var ForwardStream = module.exports = function ForwardStream(options) {
9
10
var self = this ;
10
11
11
12
this . once ( 'pipe' , function ( req ) {
12
- self . outgoing = options . https ? https : http ;
13
+ var protocol = options . https ? https : http ,
14
+ outgoing = proxy . _getBase ( options ) ;
13
15
14
16
[
15
17
'host' ,
@@ -18,7 +20,7 @@ var ForwardStream = module.exports = function ForwardStream(options) {
18
20
'socketPath' ,
19
21
'agent'
20
22
] . forEach ( function ( elem ) {
21
- outgoing [ elem ] = target [ elem ] ;
23
+ outgoing [ elem ] = options [ elem ] ;
22
24
} ) ;
23
25
24
26
[
@@ -28,16 +30,15 @@ var ForwardStream = module.exports = function ForwardStream(options) {
28
30
] . forEach ( function ( elem ) {
29
31
outgoing [ elem ] = req [ elem ] ;
30
32
} ) ;
31
-
32
- } ) ;
33
-
34
- }
35
-
36
- ForwardStream . prototype . _write = function ( ) {
37
33
34
+ self . request = protocol . request ( outgoing )
35
+ } ) ;
38
36
37
+ } ;
39
38
40
- }
39
+ ForwardStream . prototype . _write = function ( chunk , encoding , callback ) {
40
+ this . request . write ( chunk , encoding , callback ) ;
41
+ } ;
41
42
42
43
util . inherits ( ForwardStream , Writable ) ;
43
44
0 commit comments