File tree 3 files changed +13
-2
lines changed
3 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,13 @@ var http = require('http'),
8
8
*/
9
9
module . exports = httpProxy . Server ;
10
10
11
+ module . exports . createProxy = function ( options ) {
12
+ return {
13
+ web : httpProxy . createRightProxy ( 'web' ) ( options ) ,
14
+ ws : httpProxy . createRightProxy ( 'ws' ) ( options )
15
+ } ;
16
+ }
17
+
11
18
/**
12
19
* Creates the proxy server.
13
20
*
Original file line number Diff line number Diff line change @@ -80,7 +80,7 @@ function createRightProxy(type) {
80
80
} ;
81
81
} ;
82
82
}
83
-
83
+ httpProxy . createRightProxy = createRightProxy ;
84
84
85
85
function ProxyServer ( options ) {
86
86
EE3 . call ( this ) ;
@@ -96,6 +96,10 @@ function ProxyServer(options) {
96
96
this . wsPasses = Object . keys ( ws ) . map ( function ( pass ) {
97
97
return ws [ pass ] ;
98
98
} ) ;
99
+
100
+ this . on ( 'error' , function ( err ) {
101
+ console . log ( err ) ;
102
+ } ) ;
99
103
}
100
104
101
105
require ( 'util' ) . inherits ( ProxyServer , EE3 ) ;
Original file line number Diff line number Diff line change @@ -117,7 +117,7 @@ web_o = Object.keys(web_o).map(function(pass) {
117
117
( options . buffer || req ) . pipe ( proxyReq ) ;
118
118
119
119
proxyReq . on ( 'response' , function ( proxyRes ) {
120
- server . emit ( 'proxyRes' , proxyRes ) ;
120
+ if ( server ) { server . emit ( 'proxyRes' , proxyRes ) ; }
121
121
for ( var i = 0 ; i < web_o . length ; i ++ ) {
122
122
if ( web_o [ i ] ( req , res , proxyRes ) ) { break ; }
123
123
}
You can’t perform that action at this time.
0 commit comments