@@ -53,120 +53,3 @@ sys.puts('started another http server on port 8090'.green)
53
53
54
54
sys . puts ( 'to test the proxy server, request http://localhost:8080/ in your browser.' ) ;
55
55
sys . puts ( 'your request will proxy to the server running on port 8081' ) ;
56
-
57
-
58
- /*
59
-
60
- return;
61
-
62
-
63
- //
64
- // Simple 'hello world' response for test purposes
65
- //
66
- var helloWorld = function(req, res) {
67
- res.writeHead(200, {'Content-Type': 'text/plain'});
68
- res.write('hello world')
69
- res.end();
70
- };
71
-
72
-
73
- //
74
- // Creates the reverse proxy server with a specified latency
75
- //
76
- var startLatentProxyServer = function (server, port, proxy, latency) {
77
- var proxyServer = http.createServer(function (req, res){
78
- // Initialize the nodeProxy and start proxying the request
79
- proxy.init(req, res);
80
- setTimeout(function () {
81
- proxy.proxyRequest(server, port, req, res);
82
- }, latency);
83
- });
84
-
85
- proxyServer.listen(8081);
86
- return proxyServer;
87
- };
88
-
89
- //
90
- // Creates the 'hellonode' server
91
- //
92
- var startTargetServer = function (port) {
93
- var targetServer = http.createServer(function (req, res) {
94
- helloWorld(req, res);
95
- })
96
-
97
- targetServer.listen(port);
98
- return targetServer;
99
- };
100
-
101
- //
102
- // The default test bootstrapper with no latency
103
- //
104
- var startTest = function (proxy, port) {
105
- testServers.noLatency = [];
106
- testServers.noLatency.push(startProxyServer('127.0.0.1', port, proxy));
107
- testServers.noLatency.push(startTargetServer(port));
108
- };
109
-
110
- //
111
- // The test bootstrapper with some latency
112
- //
113
- var startTestWithLatency = function (proxy, port) {
114
- testServers.latency = [];
115
- testServers.latency.push(startLatentProxyServer('127.0.0.1', port, proxy, 2000));
116
- testServers.latency.push(startTargetServer(port));
117
- };
118
-
119
-
120
- sys.puts('node-http-proxy has started!'.green);
121
-
122
- // start the http-proxy
123
- var proxy = new (NodeProxy);
124
- startTest(proxy, 8082);
125
-
126
-
127
- // start a second http server (which we will reverse proxy our requests to)
128
-
129
-
130
- return;
131
-
132
-
133
- vows.describe('node-proxy').addBatch({
134
- "When an incoming request is proxied to the helloNode server" : {
135
- "with no latency" : {
136
- topic: function () {
137
- var proxy = new (NodeProxy);
138
- startTest(proxy, 8082);
139
- proxy.emitter.addListener('end', this.callback);
140
-
141
- var client = http.createClient(8080, '127.0.0.1');
142
- var request = client.request('GET', '/');
143
- request.end();
144
- },
145
- "it should received 'hello world'": function (err, body) {
146
- assert.equal(body, 'hello world');
147
- testServers.noLatency.forEach(function (server) {
148
- server.close();
149
- })
150
- }
151
- },
152
- "with latency": {
153
- topic: function () {
154
- var proxy = new (NodeProxy);
155
- startTestWithLatency(proxy, 8083);
156
- proxy.emitter.addListener('end', this.callback);
157
-
158
- var client = http.createClient(8081, '127.0.0.1');
159
- var request = client.request('GET', '/');
160
- request.end();
161
- },
162
- "it should receive 'hello world'": function (err, body) {
163
- assert.equal(body, 'hello world');
164
- testServers.latency.forEach(function (server) {
165
- server.close();
166
- })
167
- }
168
- }
169
- }
170
- }).export(module);
171
-
172
- */
0 commit comments