@@ -39,33 +39,31 @@ var welcome = '\
39
39
# # # # # # # # #### # # # \n' ;
40
40
sys . puts ( welcome . rainbow . bold ) ;
41
41
42
- // create regular http proxy server
42
+
43
+ /****** basic http proxy server ******/
43
44
httpProxy . createServer ( 'localhost' , 9000 ) . listen ( 8000 ) ;
44
45
sys . puts ( 'http proxy server' . blue + ' started ' . green . bold + 'on port ' . blue + '8000' . yellow ) ;
45
46
46
- // http proxy server with latency
47
+ /****** http proxy server with latency******/
47
48
httpProxy . createServer ( function ( req , res , proxy ) {
48
49
setTimeout ( function ( ) {
49
50
proxy . proxyRequest ( 'localhost' , 9000 , req , res ) ;
50
51
} , 200 )
51
52
} ) . listen ( 8001 ) ;
52
53
sys . puts ( 'http proxy server ' . blue + 'started ' . green . bold + 'on port ' . blue + '8001 ' . yellow + 'with latency' . magenta . underline ) ;
53
54
54
-
55
- // http proxy server with latency
55
+ /****** http server with proxyRequest handler and latency******/
56
56
http . createServer ( function ( req , res ) {
57
+ var proxy = new httpProxy . HttpProxy ;
58
+ proxy . watch ( req , res ) ;
59
+
57
60
setTimeout ( function ( ) {
58
-
59
- var proxy = new httpProxy . HttpProxy ;
60
- proxy . watch ( req , res ) ;
61
61
proxy . proxyRequest ( 'localhost' , 9000 , req , res ) ;
62
-
63
- } , 200 )
62
+ } , 200 ) ;
64
63
} ) . listen ( 8002 ) ;
65
- sys . puts ( 'http proxy server ' . blue + 'started ' . green . bold + 'on port ' . blue + '8002 ' . yellow + 'with latency' . magenta . underline ) ;
66
-
64
+ sys . puts ( 'http server ' . blue + 'started ' . green . bold + 'on port ' . blue + '8002 ' . yellow + 'with proxyRequest handler' . cyan . underline + ' and latency' . magenta ) ;
67
65
68
- // create regular http server
66
+ /****** regular http server ******/
69
67
http . createServer ( function ( req , res ) {
70
68
res . writeHead ( 200 , { 'Content-Type' : 'text/plain' } ) ;
71
69
res . write ( 'request successfully proxied: ' + req . url + '\n' + JSON . stringify ( req . headers , true , 2 ) ) ;
0 commit comments