Chromium Code Reviews| 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:async"; |
| 6 import "dart:io"; | 6 import "dart:io"; |
| 7 import "dart:uri"; | 7 import "dart:uri"; |
| 8 | 8 |
| 9 class Server { | 9 class Server { |
| 10 HttpServer server; | 10 HttpServer server; |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 182 }); | 182 }); |
| 183 } | 183 } |
| 184 | 184 |
| 185 int testProxyDoneCount = 0; | 185 int testProxyDoneCount = 0; |
| 186 void testProxy() { | 186 void testProxy() { |
| 187 setupProxyServer().then((proxyServer) { | 187 setupProxyServer().then((proxyServer) { |
| 188 setupServer(1, directRequestPaths: ["/4"]).then((server) { | 188 setupServer(1, directRequestPaths: ["/4"]).then((server) { |
| 189 setupServer(1, directRequestPaths: ["/4"], secure: true).then((secureServer) { | 189 setupServer(1, directRequestPaths: ["/4"], secure: true).then((secureServer) { |
| 190 HttpClient client = new HttpClient(); | 190 HttpClient client = new HttpClient(); |
| 191 | 191 |
| 192 List<String> proxy = | 192 List<String> proxy; |
| 193 ["PROXY localhost:${proxyServer.port}", | 193 if (Platform.operatingSystem == "windows") { |
| 194 "PROXY localhost:${proxyServer.port}; PROXY hede.hule.hest:8080", | 194 proxy = |
| 195 "PROXY hede.hule.hest:8080; PROXY localhost:${proxyServer.port}", | 195 ["PROXY localhost:${proxyServer.port}", |
| 196 "PROXY hede.hule.hest:8080; PROXY hede.hule.hest:8181;" | 196 "PROXY localhost:${proxyServer.port}; PROXY hede.hule.hest:8080", |
|
Anders Johnsen
2013/02/25 16:26:26
I still see a weird name here.
Søren Gjesse
2013/02/25 16:28:57
It should (hopefully) never get to that as the se
| |
| 197 " PROXY localhost:${proxyServer.port}", | 197 "PROXY localhost:${proxyServer.port}", |
| 198 "PROXY hede.hule.hest:8080; PROXY hede.hule.hest:8181; DIRECT", | 198 "" |
| 199 "PROXY localhost:${proxyServer.port}; DIRECT"]; | 199 " PROXY localhost:${proxyServer.port}", |
| 200 | 200 "DIRECT", |
| 201 "PROXY localhost:${proxyServer.port}; DIRECT"]; | |
| 202 } else { | |
| 203 proxy = | |
| 204 ["PROXY localhost:${proxyServer.port}", | |
| 205 "PROXY localhost:${proxyServer.port}; PROXY hede.hule.hest:8080", | |
| 206 "PROXY hede.hule.hest:8080; PROXY localhost:${proxyServer.port}", | |
| 207 "PROXY hede.hule.hest:8080; PROXY hede.hule.hest:8181;" | |
| 208 " PROXY localhost:${proxyServer.port}", | |
| 209 "PROXY hede.hule.hest:8080; PROXY hede.hule.hest:8181; DIRECT", | |
| 210 "PROXY localhost:${proxyServer.port}; DIRECT"]; | |
| 211 } | |
| 201 client.findProxy = (Uri uri) { | 212 client.findProxy = (Uri uri) { |
| 202 // Pick the proxy configuration based on the request path. | 213 // Pick the proxy configuration based on the request path. |
| 203 int index = int.parse(uri.path.substring(1)); | 214 int index = int.parse(uri.path.substring(1)); |
| 204 return proxy[index]; | 215 return proxy[index]; |
| 205 }; | 216 }; |
| 206 | 217 |
| 207 for (int i = 0; i < proxy.length; i++) { | 218 for (int i = 0; i < proxy.length; i++) { |
| 208 test(bool secure) { | 219 test(bool secure) { |
| 209 String url = secure | 220 String url = secure |
| 210 ? "https://localhost:${secureServer.port}/$i" | 221 ? "https://localhost:${secureServer.port}/$i" |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 241 int testProxyChainDoneCount = 0; | 252 int testProxyChainDoneCount = 0; |
| 242 void testProxyChain() { | 253 void testProxyChain() { |
| 243 // Setup two proxy servers having the first using the second as its proxy. | 254 // Setup two proxy servers having the first using the second as its proxy. |
| 244 setupProxyServer().then((proxyServer1) { | 255 setupProxyServer().then((proxyServer1) { |
| 245 setupProxyServer().then((proxyServer2) { | 256 setupProxyServer().then((proxyServer2) { |
| 246 proxyServer1.client.findProxy = (_) => "PROXY 127.0.0.1:${proxyServer2.port}"; | 257 proxyServer1.client.findProxy = (_) => "PROXY 127.0.0.1:${proxyServer2.port}"; |
| 247 | 258 |
| 248 setupServer(2, directRequestPaths: ["/4"]).then((server) { | 259 setupServer(2, directRequestPaths: ["/4"]).then((server) { |
| 249 HttpClient client = new HttpClient(); | 260 HttpClient client = new HttpClient(); |
| 250 | 261 |
| 251 List<String> proxy = | 262 List<String> proxy; |
| 252 ["PROXY localhost:${proxyServer1.port}", | 263 if (Platform.operatingSystem == "windows") { |
| 253 "PROXY localhost:${proxyServer1.port}; PROXY hede.hule.hest:8080", | 264 proxy = |
| 254 "PROXY hede.hule.hest:8080; PROXY localhost:${proxyServer1.port}", | 265 ["PROXY localhost:${proxyServer1.port}", |
| 255 "PROXY hede.hule.hest:8080; PROXY hede.hule.hest:8181; PROXY localhost: ${proxyServer1.port}", | 266 "PROXY localhost:${proxyServer1.port}; PROXY hede.hule.hest:8080", |
|
Anders Johnsen
2013/02/25 16:26:26
Ditto.
Søren Gjesse
2013/02/25 16:28:57
Ditto.
| |
| 256 "PROXY hede.hule.hest:8080; PROXY hede.hule.hest:8181; DIRECT", | 267 "PROXY localhost:${proxyServer1.port}", |
| 257 "PROXY localhost:${proxyServer1.port}; DIRECT"]; | 268 "PROXY localhost:${proxyServer1.port}", |
| 269 "DIRECT", | |
| 270 "PROXY localhost:${proxyServer1.port}; DIRECT"]; | |
| 271 } else { | |
| 272 proxy = | |
| 273 ["PROXY localhost:${proxyServer1.port}", | |
| 274 "PROXY localhost:${proxyServer1.port}; PROXY hede.hule.hest:8080", | |
| 275 "PROXY hede.hule.hest:8080; PROXY localhost:${proxyServer1.port}", | |
| 276 "PROXY hede.hule.hest:8080; PROXY hede.hule.hest:8181;" | |
| 277 " PROXY localhost:${proxyServer1.port}", | |
| 278 "PROXY hede.hule.hest:8080; PROXY hede.hule.hest:8181; DIRECT", | |
| 279 "PROXY localhost:${proxyServer1.port}; DIRECT"]; | |
| 280 } | |
| 258 | 281 |
| 259 client.findProxy = (Uri uri) { | 282 client.findProxy = (Uri uri) { |
| 260 // Pick the proxy configuration based on the request path. | 283 // Pick the proxy configuration based on the request path. |
| 261 int index = int.parse(uri.path.substring(1)); | 284 int index = int.parse(uri.path.substring(1)); |
| 262 return proxy[index]; | 285 return proxy[index]; |
| 263 }; | 286 }; |
| 264 | 287 |
| 265 for (int i = 0; i < proxy.length; i++) { | 288 for (int i = 0; i < proxy.length; i++) { |
| 266 client.getUrl(Uri.parse("http://127.0.0.1:${server.port}/$i")) | 289 client.getUrl(Uri.parse("http://127.0.0.1:${server.port}/$i")) |
| 267 .then((HttpClientRequest clientRequest) { | 290 .then((HttpClientRequest clientRequest) { |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 337 main() { | 360 main() { |
| 338 InitializeSSL(); | 361 InitializeSSL(); |
| 339 testInvalidProxy(); | 362 testInvalidProxy(); |
| 340 testDirectProxy(); | 363 testDirectProxy(); |
| 341 testProxy(); | 364 testProxy(); |
| 342 testProxyChain(); | 365 testProxyChain(); |
| 343 // This test is not normally run. It can be used for locally testing | 366 // This test is not normally run. It can be used for locally testing |
| 344 // with a real proxy server (e.g. Apache). | 367 // with a real proxy server (e.g. Apache). |
| 345 //testRealProxy(); | 368 //testRealProxy(); |
| 346 } | 369 } |
| OLD | NEW |