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 | 5 |
6 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
7 import "dart:async"; | 7 import "dart:async"; |
8 import "dart:io"; | 8 import "dart:io"; |
9 import "dart:uri"; | 9 import "dart:uri"; |
10 | 10 |
11 Future<HttpServer> setupServer() { | 11 Future<HttpServer> setupServer() { |
12 Completer completer = new Completer(); | 12 Completer completer = new Completer(); |
13 HttpServer.bind().then((server) { | 13 HttpServer.bind("127.0.0.1", 0).then((server) { |
14 | 14 |
15 var handlers = new Map<String, Function>(); | 15 var handlers = new Map<String, Function>(); |
16 addRequestHandler(String path, void handler(HttpRequest request, | 16 addRequestHandler(String path, void handler(HttpRequest request, |
17 HttpResponse response)) { | 17 HttpResponse response)) { |
18 handlers[path] = handler; | 18 handlers[path] = handler; |
19 } | 19 } |
20 | 20 |
21 server.listen((HttpRequest request) { | 21 server.listen((HttpRequest request) { |
22 if (handlers.containsKey(request.uri.path)) { | 22 if (handlers.containsKey(request.uri.path)) { |
23 handlers[request.uri.path](request, request.response); | 23 handlers[request.uri.path](request, request.response); |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 testManualRedirect(); | 374 testManualRedirect(); |
375 testManualRedirectWithHeaders(); | 375 testManualRedirectWithHeaders(); |
376 testAutoRedirect(); | 376 testAutoRedirect(); |
377 testAutoRedirectWithHeaders(); | 377 testAutoRedirectWithHeaders(); |
378 testAutoRedirect301POST(); | 378 testAutoRedirect301POST(); |
379 testAutoRedirect303POST(); | 379 testAutoRedirect303POST(); |
380 testAutoRedirectLimit(); | 380 testAutoRedirectLimit(); |
381 testRedirectLoop(); | 381 testRedirectLoop(); |
382 testRedirectClosingConnection(); | 382 testRedirectClosingConnection(); |
383 } | 383 } |
OLD | NEW |