8
8
9
9
var vows = require ( 'vows' ) ,
10
10
sys = require ( 'sys' ) ,
11
- colors = require ( './vendor/ colors' )
11
+ colors = require ( 'colors' )
12
12
assert = require ( 'assert' ) ,
13
13
http = require ( 'http' ) ;
14
14
15
15
var HttpProxy = require ( './lib/node-http-proxy' ) . HttpProxy ;
16
16
var testServers = { } ;
17
17
18
18
19
- // regular http server
19
+ // ascii art from http://github.com/marak/asciimo
20
+ var welcome = '\
21
+ # # ##### ##### ##### ##### ##### #### # # # # \n\
22
+ # # # # # # # # # # # # # # # # \n\
23
+ ###### # # # # ##### # # # # # # ## # \n\
24
+ # # # # ##### ##### ##### # # ## # \n\
25
+ # # # # # # # # # # # # # \n\
26
+ # # # # # # # # #### # # # \n' ;
27
+ sys . puts ( welcome . rainbow . bold ) ;
28
+
29
+ // create regular http proxy server
20
30
http . createServer ( function ( req , res ) {
21
- // Initialize the nodeProxy and start proxying the request
22
31
var proxy = new ( HttpProxy ) ;
23
32
proxy . init ( req , res ) ;
24
- // lets proxy the request to another service
25
- proxy . proxyRequest ( 'localhost' , '8081' , req , res ) ;
26
-
27
- } ) . listen ( 8080 ) ;
28
- sys . puts ( 'started a http server on port 8080' . green )
33
+ proxy . proxyRequest ( 'localhost' , '9000' , req , res ) ;
34
+ } ) . listen ( 8000 ) ;
35
+ sys . puts ( 'http proxy server' . blue + ' started ' . green . bold + 'on port ' . blue + '8000' . yellow ) ;
29
36
30
- // http server with latency
37
+ // http proxy server with latency
31
38
http . createServer ( function ( req , res ) {
32
- // Initialize the nodeProxy and start proxying the request
33
39
var proxy = new ( HttpProxy ) ;
34
40
proxy . init ( req , res ) ;
35
-
36
- // lets proxy the request to another service
37
41
setTimeout ( function ( ) {
38
- proxy . proxyRequest ( 'localhost' , '8090 ' , req , res ) ;
42
+ proxy . proxyRequest ( 'localhost' , '9000 ' , req , res ) ;
39
43
} , 200 )
40
-
41
- } ) . listen ( 8081 ) ;
42
- sys . puts ( 'started a http server with latency on port 8081' . green )
43
-
44
-
44
+ } ) . listen ( 8001 ) ;
45
+ sys . puts ( 'http proxy server ' . blue + 'started ' . green . bold + 'on port ' . blue + '8001 ' . yellow + 'with latency' . magenta . underline ) ;
45
46
47
+ // create regular http server
46
48
http . createServer ( function ( req , res ) {
47
49
res . writeHead ( 200 , { 'Content-Type' : 'text/plain' } ) ;
48
50
res . write ( 'foo' ) ;
49
51
res . end ( ) ;
50
- } ) . listen ( 8090 ) ;
51
- sys . puts ( 'started another http server on port 8090' . green )
52
-
53
-
54
- sys . puts ( 'to test the proxy server, request http://localhost:8080/ in your browser.' ) ;
55
- sys . puts ( 'your request will proxy to the server running on port 8081' ) ;
52
+ } ) . listen ( 9000 ) ;
53
+ sys . puts ( 'http server ' . blue + 'started ' . green . bold + 'on port ' . blue + '9000 ' . yellow ) ;
54
+ //sys.puts('to test the proxy server, request http://localhost:8080/ in your browser.');
55
+ //sys.puts('your request will proxy to the server running on port 8081');
0 commit comments