File tree 1 file changed +36
-0
lines changed
1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change
1
+ var http = require ( 'http' ) ,
2
+ httpProxy = require ( '../lib/http-proxy' ) ;
3
+
4
+ var connections = [ ] ,
5
+ go ;
6
+
7
+
8
+ //
9
+ // Target Http Server
10
+ //
11
+ // to check apparent problems with concurrent connections
12
+ // make a server which only responds when there is a given nubmer on connections
13
+ //
14
+ http . createServer ( function ( req , res ) {
15
+ connections . push ( function ( ) {
16
+ res . writeHead ( 200 , { 'Content-Type' : 'text/plain' } ) ;
17
+ res . write ( 'request successfully proxied to: ' + req . url + '\n' + JSON . stringify ( req . headers , true , 2 ) ) ;
18
+ res . end ( ) ;
19
+ } ) ;
20
+
21
+ process . stdout . write ( connections . length + ', ' ) ;
22
+
23
+ if ( connections . length > 10 || go ) {
24
+ go = true ;
25
+ while ( connections . length ) {
26
+ connections . shift ( ) ( ) ;
27
+ }
28
+ }
29
+ } ) . listen ( 9000 ) ;
30
+ console . log ( "Web server listening on port 9000" ) ;
31
+
32
+ //
33
+ // Basic Http Proxy Server
34
+ //
35
+ httpProxy . createProxyServer ( { target :'http://localhost:9000' } ) . listen ( 8000 ) ;
36
+ console . log ( "Proxy server listening on port 8000" ) ;
You can’t perform that action at this time.
0 commit comments