OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
| 5 import "dart:async"; |
5 import "dart:io"; | 6 import "dart:io"; |
6 import "dart:uri"; | 7 import "dart:uri"; |
7 | 8 |
8 class Server { | 9 class Server { |
9 HttpServer server; | 10 HttpServer server; |
10 bool secure; | 11 bool secure; |
11 int proxyHops; | 12 int proxyHops; |
12 List<String> directRequestPaths; | 13 List<String> directRequestPaths; |
13 int requestCount = 0; | 14 int requestCount = 0; |
14 | 15 |
15 Server(this.proxyHops, this.directRequestPaths, this.secure) { | 16 Server(this.proxyHops, this.directRequestPaths, this.secure); |
16 server = secure ? new HttpsServer() : new HttpServer(); | |
17 } | |
18 | 17 |
19 void start() { | 18 Future<Server> start() { |
20 server.listen("127.0.0.1", 0, certificate_name: 'CN=localhost'); | 19 var x = new Completer(); |
21 server.defaultRequestHandler = | 20 Future f = secure |
22 (HttpRequest request, HttpResponse response) { | 21 ? HttpServer.bindSecure( |
23 requestCount++; | 22 "127.0.0.1", 0, certificateName: 'localhost_cert') |
24 // Check whether a proxy or direct connection is expected. | 23 : HttpServer.bind(); |
25 bool direct = directRequestPaths.reduce( | 24 return f.then((s) { |
26 false, | 25 server = s; |
27 (prev, path) => prev ? prev : path == request.path); | 26 x.complete(this); |
28 if (!direct && proxyHops > 0) { | 27 server.listen((request) { |
29 Expect.isNotNull(request.headers[HttpHeaders.VIA]); | 28 var response = request.response; |
30 Expect.equals(1, request.headers[HttpHeaders.VIA].length); | 29 requestCount++; |
31 Expect.equals( | 30 // Check whether a proxy or direct connection is expected. |
32 proxyHops, | 31 bool direct = directRequestPaths.reduce( |
33 request.headers[HttpHeaders.VIA][0].split(",").length); | 32 false, |
34 } else { | 33 (prev, path) => prev ? prev : path == request.uri.path); |
35 Expect.isNull(request.headers[HttpHeaders.VIA]); | 34 if (!direct && proxyHops > 0) { |
36 } | 35 Expect.isNotNull(request.headers[HttpHeaders.VIA]); |
37 StringInputStream stream = new StringInputStream(request.inputStream); | 36 Expect.equals(1, request.headers[HttpHeaders.VIA].length); |
38 StringBuffer body = new StringBuffer(); | 37 Expect.equals( |
39 stream.onData = () => body.add(stream.read()); | 38 proxyHops, |
40 stream.onClosed = () { | 39 request.headers[HttpHeaders.VIA][0].split(",").length); |
41 String path = request.path.substring(1); | 40 } else { |
42 String content = "$path$path$path"; | 41 Expect.isNull(request.headers[HttpHeaders.VIA]); |
43 Expect.equals(content, body.toString()); | 42 } |
44 response.outputStream.writeString(request.path); | 43 var body = new StringBuffer(); |
45 response.outputStream.close(); | 44 request.listen( |
46 }; | 45 (data) { |
47 }; | 46 body.add(new String.fromCharCodes(data)); |
| 47 }, |
| 48 onDone: () { |
| 49 String path = request.uri.path.substring(1); |
| 50 String content = "$path$path$path"; |
| 51 Expect.equals(content, body.toString()); |
| 52 response.addString(request.uri.path); |
| 53 response.close(); |
| 54 }); |
| 55 }); |
| 56 return x.future; |
| 57 }); |
48 } | 58 } |
49 | 59 |
50 void shutdown() { | 60 void shutdown() { |
51 server.close(); | 61 server.close(); |
52 } | 62 } |
53 | 63 |
54 int get port => server.port; | 64 int get port => server.port; |
55 } | 65 } |
56 | 66 |
57 Server setupServer(int proxyHops, | 67 Future<Server> setupServer(int proxyHops, |
58 {List<String> directRequestPaths: const <String>[], | 68 {List<String> directRequestPaths: const <String>[], |
59 secure: false}) { | 69 secure: false}) { |
60 Server server = new Server(proxyHops, directRequestPaths, secure); | 70 Server server = new Server(proxyHops, directRequestPaths, secure); |
61 server.start(); | 71 return server.start(); |
62 return server; | |
63 } | 72 } |
64 | 73 |
65 class ProxyServer { | 74 class ProxyServer { |
66 HttpServer server; | 75 HttpServer server; |
67 HttpClient client; | 76 HttpClient client; |
68 int requestCount = 0; | 77 int requestCount = 0; |
69 | 78 |
70 ProxyServer() : server = new HttpServer(), client = new HttpClient(); | 79 ProxyServer() : client = new HttpClient(); |
71 | 80 |
72 void start() { | 81 Future<ProxyServer> start() { |
73 server.listen("127.0.0.1", 0); | 82 var x = new Completer(); |
74 server.defaultRequestHandler = | 83 HttpServer.bind().then((s) { |
75 (HttpRequest request, HttpResponse response) { | 84 server = s; |
76 requestCount++; | 85 x.complete(this); |
77 // Open the connection from the proxy. | 86 server.listen((HttpRequest request) { |
78 HttpClientConnection conn = | 87 requestCount++; |
79 client.openUrl(request.method, Uri.parse(request.path)); | 88 // Open the connection from the proxy. |
80 conn.onRequest = (HttpClientRequest clientRequest) { | 89 client.openUrl(request.method, request.uri) |
| 90 .then((HttpClientRequest clientRequest) { |
81 // Forward all headers. | 91 // Forward all headers. |
82 request.headers.forEach((String name, List<String> values) { | 92 request.headers.forEach((String name, List<String> values) { |
83 values.forEach((String value) { | 93 values.forEach((String value) { |
84 if (name != "content-length" && name != "via") { | 94 if (name != "content-length" && name != "via") { |
85 clientRequest.headers.add(name, value); | 95 clientRequest.headers.add(name, value); |
86 } | 96 } |
87 }); | 97 }); |
88 }); | 98 }); |
89 // Special handling of Content-Length and Via. | 99 // Special handling of Content-Length and Via. |
90 clientRequest.contentLength = request.contentLength; | 100 clientRequest.contentLength = request.contentLength; |
91 List<String> via = request.headers[HttpHeaders.VIA]; | 101 List<String> via = request.headers[HttpHeaders.VIA]; |
92 String viaPrefix = via == null ? "" : "${via[0]}, "; | 102 String viaPrefix = via == null ? "" : "${via[0]}, "; |
93 clientRequest.headers.add( | 103 clientRequest.headers.add( |
94 HttpHeaders.VIA, "${viaPrefix}1.1 localhost:$port"); | 104 HttpHeaders.VIA, "${viaPrefix}1.1 localhost:$port"); |
95 // Copy all content. | 105 // Copy all content. |
96 request.inputStream.pipe(clientRequest.outputStream); | 106 request.pipe(clientRequest); |
97 }; | 107 return clientRequest.response; |
98 conn.onResponse = (HttpClientResponse clientResponse) { | 108 }) |
99 clientResponse.inputStream.pipe(response.outputStream); | 109 .then((HttpClientResponse clientResponse) { |
100 }; | 110 clientResponse.pipe(request.response); |
101 }; | 111 }); |
| 112 }); |
| 113 }); |
| 114 return x.future; |
102 } | 115 } |
103 | 116 |
104 void shutdown() { | 117 void shutdown() { |
105 server.close(); | 118 server.close(); |
106 client.shutdown(); | 119 client.close(); |
107 } | 120 } |
108 | 121 |
109 int get port => server.port; | 122 int get port => server.port; |
110 } | 123 } |
111 | 124 |
112 ProxyServer setupProxyServer() { | 125 Future<ProxyServer> setupProxyServer() { |
113 ProxyServer proxyServer = new ProxyServer(); | 126 ProxyServer proxyServer = new ProxyServer(); |
114 proxyServer.start(); | 127 return proxyServer.start(); |
115 return proxyServer; | |
116 } | 128 } |
117 | 129 |
118 testInvalidProxy() { | 130 testInvalidProxy() { |
119 HttpClient client = new HttpClient(); | 131 HttpClient client = new HttpClient(); |
120 | 132 |
121 // TODO(sgjesse): This should not throw errors, but call | 133 client.findProxy = (Uri uri) => ""; |
122 // HttpClientConnection onError. | 134 client.getUrl(Uri.parse("http://www.google.com/test")) |
| 135 .catchError((error) {}, test: (e) => e is HttpException); |
| 136 |
123 client.findProxy = (Uri uri) => "XXX"; | 137 client.findProxy = (Uri uri) => "XXX"; |
124 Expect.throws( | 138 client.getUrl(Uri.parse("http://www.google.com/test")) |
125 () => client.getUrl(Uri.parse("http://www.google.com/test")), | 139 .catchError((error) {}, test: (e) => e is HttpException); |
126 (e) => e is HttpException); | |
127 | 140 |
128 client.findProxy = (Uri uri) => "PROXY www.google.com"; | 141 client.findProxy = (Uri uri) => "PROXY www.google.com"; |
129 Expect.throws( | 142 client.getUrl(Uri.parse("http://www.google.com/test")) |
130 () => client.getUrl(Uri.parse("http://www.google.com/test")), | 143 .catchError((error) {}, test: (e) => e is HttpException); |
131 (e) => e is HttpException); | |
132 | 144 |
133 client.findProxy = (Uri uri) => "PROXY www.google.com:http"; | 145 client.findProxy = (Uri uri) => "PROXY www.google.com:http"; |
134 Expect.throws( | 146 client.getUrl(Uri.parse("http://www.google.com/test")) |
135 () => client.getUrl(Uri.parse("http://www.google.com/test")), | 147 .catchError((error) {}, test: (e) => e is HttpException); |
136 (e) => e is HttpException); | |
137 } | 148 } |
138 | 149 |
139 int testDirectDoneCount = 0; | 150 int testDirectDoneCount = 0; |
140 void testDirectProxy() { | 151 void testDirectProxy() { |
141 Server server = setupServer(0); | 152 setupServer(0).then((server) { |
142 HttpClient client = new HttpClient(); | 153 HttpClient client = new HttpClient(); |
143 List<String> proxy = | 154 List<String> proxy = |
144 ["DIRECT", " DIRECT ", "DIRECT ;", " DIRECT ; ", | 155 ["DIRECT", " DIRECT ", "DIRECT ;", " DIRECT ; ", |
145 ";DIRECT", " ; DIRECT ", ";;DIRECT;;"]; | 156 ";DIRECT", " ; DIRECT ", ";;DIRECT;;"]; |
146 | 157 |
147 client.findProxy = (Uri uri) { | 158 client.findProxy = (Uri uri) { |
148 int index = int.parse(uri.path.substring(1)); | 159 int index = int.parse(uri.path.substring(1)); |
149 return proxy[index]; | 160 return proxy[index]; |
150 }; | 161 }; |
151 | 162 |
152 for (int i = 0; i < proxy.length; i++) { | 163 for (int i = 0; i < proxy.length; i++) { |
153 HttpClientConnection conn = | 164 client.getUrl(Uri.parse("http://127.0.0.1:${server.port}/$i")) |
154 client.getUrl(Uri.parse("http://127.0.0.1:${server.port}/$i")); | 165 .then((HttpClientRequest clientRequest) { |
155 conn.onRequest = (HttpClientRequest clientRequest) { | 166 String content = "$i$i$i"; |
156 String content = "$i$i$i"; | 167 clientRequest.contentLength = content.length; |
157 clientRequest.contentLength = content.length; | 168 clientRequest.addString(content); |
158 clientRequest.outputStream.writeString(content); | 169 return clientRequest.close(); |
159 clientRequest.outputStream.close(); | 170 }) |
160 }; | 171 .then((HttpClientResponse response) { |
161 conn.onResponse = (HttpClientResponse response) { | 172 response.listen((_) {}, onDone: () { |
162 response.inputStream.onData = () => response.inputStream.read(); | 173 testDirectDoneCount++; |
163 response.inputStream.onClosed = () { | 174 if (testDirectDoneCount == proxy.length) { |
164 testDirectDoneCount++; | 175 Expect.equals(proxy.length, server.requestCount); |
165 if (testDirectDoneCount == proxy.length) { | 176 server.shutdown(); |
166 Expect.equals(proxy.length, server.requestCount); | 177 client.close(); |
167 server.shutdown(); | 178 } |
168 client.shutdown(); | 179 }); |
169 } | 180 }); |
170 }; | 181 } |
171 }; | 182 }); |
172 } | |
173 } | 183 } |
174 | 184 |
175 int testProxyDoneCount = 0; | 185 int testProxyDoneCount = 0; |
176 void testProxy() { | 186 void testProxy() { |
177 ProxyServer proxyServer = setupProxyServer(); | 187 setupProxyServer().then((proxyServer) { |
178 Server server = setupServer(1, directRequestPaths: ["/4"]); | 188 setupServer(1, directRequestPaths: ["/4"]).then((server) { |
179 Server secureServer = setupServer(1, directRequestPaths: ["/4"], secure: true)
; | 189 setupServer(1, directRequestPaths: ["/4"], secure: true).then((secureServer) { |
180 HttpClient client = new HttpClient(); | 190 HttpClient client = new HttpClient(); |
181 | 191 |
182 List<String> proxy = | 192 List<String> proxy = |
183 ["PROXY localhost:${proxyServer.port}", | 193 ["PROXY localhost:${proxyServer.port}", |
184 "PROXY localhost:${proxyServer.port}; PROXY hede.hule.hest:8080", | 194 "PROXY localhost:${proxyServer.port}; PROXY hede.hule.hest:8080", |
185 "PROXY hede.hule.hest:8080; PROXY localhost:${proxyServer.port}", | 195 "PROXY hede.hule.hest:8080; PROXY localhost:${proxyServer.port}", |
186 "PROXY hede.hule.hest:8080; PROXY hede.hule.hest:8181; PROXY localhost:${
proxyServer.port}", | 196 "PROXY hede.hule.hest:8080; PROXY hede.hule.hest:8181;" |
187 "PROXY hede.hule.hest:8080; PROXY hede.hule.hest:8181; DIRECT", | 197 " PROXY localhost:${proxyServer.port}", |
188 "PROXY localhost:${proxyServer.port}; DIRECT"]; | 198 "PROXY hede.hule.hest:8080; PROXY hede.hule.hest:8181; DIRECT", |
189 | 199 "PROXY localhost:${proxyServer.port}; DIRECT"]; |
190 client.findProxy = (Uri uri) { | 200 |
191 // Pick the proxy configuration based on the request path. | 201 client.findProxy = (Uri uri) { |
192 int index = int.parse(uri.path.substring(1)); | 202 // Pick the proxy configuration based on the request path. |
193 return proxy[index]; | 203 int index = int.parse(uri.path.substring(1)); |
194 }; | 204 return proxy[index]; |
195 | 205 }; |
196 for (int i = 0; i < proxy.length; i++) { | 206 |
197 test(bool secure) { | 207 for (int i = 0; i < proxy.length; i++) { |
198 String url = secure | 208 test(bool secure) { |
199 ? "https://localhost:${secureServer.port}/$i" | 209 String url = secure |
200 : "http://127.0.0.1:${server.port}/$i"; | 210 ? "https://localhost:${secureServer.port}/$i" |
201 | 211 : "http://127.0.0.1:${server.port}/$i"; |
202 HttpClientConnection conn = client.postUrl(Uri.parse(url)); | 212 |
203 conn.onRequest = (HttpClientRequest clientRequest) { | 213 client.postUrl(Uri.parse(url)) |
204 String content = "$i$i$i"; | 214 .then((HttpClientRequest clientRequest) { |
205 clientRequest.outputStream.writeString(content); | 215 String content = "$i$i$i"; |
206 clientRequest.outputStream.close(); | 216 clientRequest.addString(content); |
207 }; | 217 return clientRequest.close(); |
208 conn.onResponse = (HttpClientResponse response) { | 218 }) |
209 response.inputStream.onData = () => response.inputStream.read(); | 219 .then((HttpClientResponse response) { |
210 response.inputStream.onClosed = () { | 220 response.listen((_) {}, onDone: () { |
211 testProxyDoneCount++; | 221 testProxyDoneCount++; |
212 if (testProxyDoneCount == proxy.length * 2) { | 222 if (testProxyDoneCount == proxy.length * 2) { |
213 Expect.equals(proxy.length, server.requestCount); | 223 Expect.equals(proxy.length, server.requestCount); |
214 proxyServer.shutdown(); | 224 proxyServer.shutdown(); |
215 server.shutdown(); | 225 server.shutdown(); |
216 secureServer.shutdown(); | 226 secureServer.shutdown(); |
217 client.shutdown(); | 227 client.close(); |
218 } | 228 } |
219 }; | 229 }); |
220 }; | 230 }); |
221 } | 231 } |
222 | 232 |
223 test(false); | 233 test(false); |
224 test(true); | 234 test(true); |
225 } | 235 } |
| 236 }); |
| 237 }); |
| 238 }); |
226 } | 239 } |
227 | 240 |
228 int testProxyChainDoneCount = 0; | 241 int testProxyChainDoneCount = 0; |
229 void testProxyChain() { | 242 void testProxyChain() { |
230 // Setup two proxy servers having the first using the second as its proxy. | 243 // Setup two proxy servers having the first using the second as its proxy. |
231 ProxyServer proxyServer1 = setupProxyServer(); | 244 setupProxyServer().then((proxyServer1) { |
232 ProxyServer proxyServer2 = setupProxyServer(); | 245 setupProxyServer().then((proxyServer2) { |
233 proxyServer1.client.findProxy = (_) => "PROXY 127.0.0.1:${proxyServer2.port}"; | 246 proxyServer1.client.findProxy = (_) => "PROXY 127.0.0.1:${proxyServer2.port}"; |
234 | 247 |
235 Server server = setupServer(2, directRequestPaths: ["/4"]); | 248 setupServer(2, directRequestPaths: ["/4"]).then((server) { |
236 HttpClient client = new HttpClient(); | 249 HttpClient client = new HttpClient(); |
237 | 250 |
238 List<String> proxy = | 251 List<String> proxy = |
239 ["PROXY localhost:${proxyServer1.port}", | 252 ["PROXY localhost:${proxyServer1.port}", |
240 "PROXY localhost:${proxyServer1.port}; PROXY hede.hule.hest:8080", | 253 "PROXY localhost:${proxyServer1.port}; PROXY hede.hule.hest:8080", |
241 "PROXY hede.hule.hest:8080; PROXY localhost:${proxyServer1.port}", | 254 "PROXY hede.hule.hest:8080; PROXY localhost:${proxyServer1.port}", |
242 "PROXY hede.hule.hest:8080; PROXY hede.hule.hest:8181; PROXY localhost:${
proxyServer1.port}", | 255 "PROXY hede.hule.hest:8080; PROXY hede.hule.hest:8181; PROXY localhost:
${proxyServer1.port}", |
243 "PROXY hede.hule.hest:8080; PROXY hede.hule.hest:8181; DIRECT", | 256 "PROXY hede.hule.hest:8080; PROXY hede.hule.hest:8181; DIRECT", |
244 "PROXY localhost:${proxyServer1.port}; DIRECT"]; | 257 "PROXY localhost:${proxyServer1.port}; DIRECT"]; |
245 | 258 |
246 client.findProxy = (Uri uri) { | 259 client.findProxy = (Uri uri) { |
247 // Pick the proxy configuration based on the request path. | 260 // Pick the proxy configuration based on the request path. |
248 int index = int.parse(uri.path.substring(1)); | 261 int index = int.parse(uri.path.substring(1)); |
249 return proxy[index]; | 262 return proxy[index]; |
250 }; | 263 }; |
251 | 264 |
252 for (int i = 0; i < proxy.length; i++) { | 265 for (int i = 0; i < proxy.length; i++) { |
253 HttpClientConnection conn = | 266 client.getUrl(Uri.parse("http://127.0.0.1:${server.port}/$i")) |
254 client.getUrl(Uri.parse("http://127.0.0.1:${server.port}/$i")); | 267 .then((HttpClientRequest clientRequest) { |
255 conn.onRequest = (HttpClientRequest clientRequest) { | 268 String content = "$i$i$i"; |
256 String content = "$i$i$i"; | 269 clientRequest.contentLength = content.length; |
257 clientRequest.contentLength = content.length; | 270 clientRequest.addString(content); |
258 clientRequest.outputStream.writeString(content); | 271 return clientRequest.close(); |
259 clientRequest.outputStream.close(); | 272 }) |
260 }; | 273 .then((HttpClientResponse response) { |
261 conn.onResponse = (HttpClientResponse response) { | 274 response.listen((_) {}, onDone: () { |
262 response.inputStream.onData = () => response.inputStream.read(); | 275 testProxyChainDoneCount++; |
263 response.inputStream.onClosed = () { | 276 if (testProxyChainDoneCount == proxy.length) { |
264 testProxyChainDoneCount++; | 277 Expect.equals(proxy.length, server.requestCount); |
265 if (testProxyChainDoneCount == proxy.length) { | 278 proxyServer1.shutdown(); |
266 Expect.equals(proxy.length, server.requestCount); | 279 proxyServer2.shutdown(); |
267 proxyServer1.shutdown(); | 280 server.shutdown(); |
268 proxyServer2.shutdown(); | 281 client.close(); |
269 server.shutdown(); | 282 } |
270 client.shutdown(); | 283 }); |
271 } | 284 }); |
272 }; | 285 } |
273 }; | 286 }); |
274 } | 287 }); |
| 288 }); |
275 } | 289 } |
276 | 290 |
277 int testRealProxyDoneCount = 0; | 291 int testRealProxyDoneCount = 0; |
278 void testRealProxy() { | 292 void testRealProxy() { |
279 Server server = setupServer(1); | 293 setupServer(1).then((server) { |
280 HttpClient client = new HttpClient(); | 294 HttpClient client = new HttpClient(); |
281 | 295 |
282 List<String> proxy = | 296 List<String> proxy = |
283 ["PROXY localhost:8080", | 297 ["PROXY localhost:8080", |
284 "PROXY localhost:8080; PROXY hede.hule.hest:8080", | 298 "PROXY localhost:8080; PROXY hede.hule.hest:8080", |
285 "PROXY hede.hule.hest:8080; PROXY localhost:8080", | 299 "PROXY hede.hule.hest:8080; PROXY localhost:8080", |
286 "PROXY localhost:8080; DIRECT"]; | 300 "PROXY localhost:8080; DIRECT"]; |
287 | 301 |
288 client.findProxy = (Uri uri) { | 302 client.findProxy = (Uri uri) { |
289 // Pick the proxy configuration based on the request path. | 303 // Pick the proxy configuration based on the request path. |
290 int index = int.parse(uri.path.substring(1)); | 304 int index = int.parse(uri.path.substring(1)); |
291 return proxy[index]; | 305 return proxy[index]; |
292 }; | 306 }; |
293 | 307 |
294 for (int i = 0; i < proxy.length; i++) { | 308 for (int i = 0; i < proxy.length; i++) { |
295 HttpClientConnection conn = | 309 client.getUrl(Uri.parse("http://127.0.0.1:${server.port}/$i")) |
296 client.getUrl(Uri.parse("http://127.0.0.1:${server.port}/$i")); | 310 .then((HttpClientRequest clientRequest) { |
297 conn.onRequest = (HttpClientRequest clientRequest) { | 311 String content = "$i$i$i"; |
298 String content = "$i$i$i"; | 312 clientRequest.contentLength = content.length; |
299 clientRequest.contentLength = content.length; | 313 clientRequest.addString(content); |
300 clientRequest.outputStream.writeString(content); | 314 return clientRequest.close(); |
301 clientRequest.outputStream.close(); | 315 }) |
302 }; | 316 .then((HttpClientResponse response) { |
303 conn.onResponse = (HttpClientResponse response) { | 317 response.listen((_) {}, onDone: () { |
304 response.inputStream.onData = () => response.inputStream.read(); | 318 testRealProxyDoneCount++; |
305 response.inputStream.onClosed = () { | 319 if (testRealProxyDoneCount == proxy.length) { |
306 testRealProxyDoneCount++; | 320 Expect.equals(proxy.length, server.requestCount); |
307 if (testRealProxyDoneCount == proxy.length) { | 321 server.shutdown(); |
308 Expect.equals(proxy.length, server.requestCount); | 322 client.close(); |
309 server.shutdown(); | 323 } |
310 client.shutdown(); | 324 }); |
311 } | 325 }); |
312 }; | 326 } |
313 }; | 327 }); |
314 } | |
315 } | 328 } |
316 | 329 |
317 void InitializeSSL() { | 330 void InitializeSSL() { |
318 var testPkcertDatabase = | 331 var testPkcertDatabase = |
319 new Path(new Options().script).directoryPath.append('pkcert/'); | 332 new Path(new Options().script).directoryPath.append('pkcert/'); |
320 SecureSocket.initialize(database: testPkcertDatabase.toNativePath(), | 333 SecureSocket.initialize(database: testPkcertDatabase.toNativePath(), |
321 password: 'dartdart'); | 334 password: 'dartdart'); |
322 } | 335 } |
323 | 336 |
324 main() { | 337 main() { |
325 InitializeSSL(); | 338 InitializeSSL(); |
326 testInvalidProxy(); | 339 testInvalidProxy(); |
327 testDirectProxy(); | 340 testDirectProxy(); |
328 testProxy(); | 341 testProxy(); |
329 testProxyChain(); | 342 testProxyChain(); |
330 // This test is not normally run. It can be used for locally testing | 343 // This test is not normally run. It can be used for locally testing |
331 // with a real proxy server (e.g. Apache). | 344 // with a real proxy server (e.g. Apache). |
332 // testRealProxy(); | 345 //testRealProxy(); |
333 } | 346 } |
OLD | NEW |