File tree Expand file tree Collapse file tree 3 files changed +21
-12
lines changed Expand file tree Collapse file tree 3 files changed +21
-12
lines changed Original file line number Diff line number Diff line change @@ -329,16 +329,17 @@ class ProxyServer extends ProxyCore {
329
329
// start web interface if neeeded
330
330
if ( this . proxyWebinterfaceConfig && this . proxyWebinterfaceConfig . enable ) {
331
331
this . webServerInstance = new WebInterface ( this . proxyWebinterfaceConfig , this . recorder ) ;
332
- }
333
-
334
- // start web server
335
- this . webServerInstance . start ( ) . then ( ( ) => {
336
- // start proxy core
332
+ // start web server
333
+ this . webServerInstance . start ( ) . then ( ( ) => {
334
+ // start proxy core
335
+ super . start ( ) ;
336
+ } )
337
+ . catch ( ( e ) => {
338
+ this . emit ( 'error' , e ) ;
339
+ } ) ;
340
+ } else {
337
341
super . start ( ) ;
338
- } )
339
- . catch ( ( e ) => {
340
- this . emit ( 'error' , e ) ;
341
- } ) ;
342
+ }
342
343
}
343
344
344
345
close ( ) {
Original file line number Diff line number Diff line change @@ -31,9 +31,11 @@ const ProxyServerUtil = require('../util/ProxyServerUtil.js');
31
31
32
32
testRequest ( 'http' ) ;
33
33
testRequest ( 'https' ) ;
34
+ testRequest ( 'http' , false ) ;
35
+ testRequest ( 'https' , false ) ;
34
36
35
37
// Test suites for http and https request
36
- function testRequest ( protocol = 'http' ) {
38
+ function testRequest ( protocol = 'http' , needWeb = true ) {
37
39
function constructUrl ( urlPath ) {
38
40
return generateUrl ( protocol , urlPath ) ;
39
41
}
@@ -47,7 +49,7 @@ function testRequest(protocol = 'http') {
47
49
printLog ( 'Start server for no_rule_spec' ) ;
48
50
49
51
serverInstance = new Server ( ) ;
50
- proxyServer = ProxyServerUtil . defaultProxyServer ( ) ;
52
+ proxyServer = ProxyServerUtil . defaultProxyServer ( needWeb ) ;
51
53
setTimeout ( ( ) => {
52
54
done ( ) ;
53
55
} , 2000 ) ;
Original file line number Diff line number Diff line change @@ -23,10 +23,16 @@ const DEFAULT_OPTIONS = {
23
23
*
24
24
* @return An instance of proxy, could be closed by calling `instance.close()`
25
25
*/
26
- function defaultProxyServer ( ) {
26
+ function defaultProxyServer ( webinterfaceEnable = true ) {
27
27
const AnyProxy = util . freshRequire ( '../proxy.js' ) ;
28
28
29
29
const options = util . merge ( { } , DEFAULT_OPTIONS ) ;
30
+ util . merge ( options , {
31
+ webInterface : {
32
+ enable : webinterfaceEnable ,
33
+ webPort : 8002
34
+ }
35
+ } )
30
36
const instance = new AnyProxy . ProxyServer ( options ) ;
31
37
instance . on ( 'error' , e => {
32
38
console . log ( 'server instance error' , e ) ;
You can’t perform that action at this time.
0 commit comments