1
1
var http = require ( 'http' ) ,
2
+ https = require ( 'https' ) ,
2
3
common = require ( '../common' ) ,
3
4
passes = exports ;
4
5
5
6
/*!
6
7
* Array of passes.
7
- *
8
+ *
8
9
* A `pass` is just a function that is executed on `req, socket, options`
9
10
* so that you can easily add new checks while still keeping the base
10
11
* flexible.
@@ -60,7 +61,7 @@ function XHeaders(req, socket, options) {
60
61
} ;
61
62
62
63
[ 'for' , 'port' , 'proto' ] . forEach ( function ( header ) {
63
- req . headers [ 'x-forwarded-' + header ] =
64
+ req . headers [ 'x-forwarded-' + header ] =
64
65
( req . headers [ 'x-forwarded-' + header ] || '' ) +
65
66
( req . headers [ 'x-forwarded-' + header ] ? ',' : '' ) +
66
67
values [ header ]
@@ -74,10 +75,10 @@ function XHeaders(req, socket, options) {
74
75
function stream ( req , socket , options , head ) {
75
76
common . setupSocket ( socket ) ;
76
77
77
- var proxyReq = http . request (
78
+ var proxyReq = ( options . ssl ? https : http ) . request (
78
79
common . setupOutgoing ( options . ssl || { } , options , req )
79
80
) ;
80
-
81
+
81
82
proxyReq . on ( 'upgrade' , function ( proxyRes , proxySocket , proxyHead ) {
82
83
common . setupSocket ( proxySocket ) ;
83
84
@@ -95,5 +96,5 @@ function stream(req, socket, options, head) {
95
96
96
97
] // <--
97
98
. forEach ( function ( func ) {
98
- passes [ func . name ] = func ;
99
+ passes [ func . name ] = func ;
99
100
} ) ;
0 commit comments