Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(826)

Side by Side Diff: pkg/scheduled_test/lib/scheduled_server.dart

Issue 14766006: Use 'localhost' instead of '127.0.0.1', as IPv6 connections now can occur. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 library scheduled_test.scheduled_server; 5 library scheduled_test.scheduled_server;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 import 'dart:io'; 9 import 'dart:io';
10 import 'dart:uri'; 10 import 'dart:uri';
(...skipping 30 matching lines...) Expand all
41 41
42 /// Creates a new server listening on an automatically-allocated port on 42 /// Creates a new server listening on an automatically-allocated port on
43 /// localhost. [description] is used to refer to the server in debugging 43 /// localhost. [description] is used to refer to the server in debugging
44 /// messages. 44 /// messages.
45 factory ScheduledServer([String description]) { 45 factory ScheduledServer([String description]) {
46 var id = _count++; 46 var id = _count++;
47 if (description == null) description = 'scheduled server $id'; 47 if (description == null) description = 'scheduled server $id';
48 48
49 var scheduledServer; 49 var scheduledServer;
50 scheduledServer = new ScheduledServer._(schedule(() { 50 scheduledServer = new ScheduledServer._(schedule(() {
51 return SafeHttpServer.bind("127.0.0.1", 0).then((server) { 51 return SafeHttpServer.bind("localhost", 0).then((server) {
52 server.listen(scheduledServer._handleRequest, 52 server.listen(scheduledServer._handleRequest,
53 onError: (e) => currentSchedule.signalError(e)); 53 onError: (e) => currentSchedule.signalError(e));
54 currentSchedule.onComplete.schedule(server.close); 54 currentSchedule.onComplete.schedule(server.close);
55 return server; 55 return server;
56 }); 56 });
57 }, "starting '$description'"), description); 57 }, "starting '$description'"), description);
58 return scheduledServer; 58 return scheduledServer;
59 } 59 }
60 60
61 /// The port on which the server is listening. 61 /// The port on which the server is listening.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 "when no more requests were expected."; 97 "when no more requests were expected.";
98 } 98 }
99 return _handlers.removeFirst().fn(request); 99 return _handlers.removeFirst().fn(request);
100 }).catchError((e) { 100 }).catchError((e) {
101 // Close the server so that we don't leave a dangling request. 101 // Close the server so that we don't leave a dangling request.
102 _server.then((s) => s.close()); 102 _server.then((s) => s.close());
103 throw e; 103 throw e;
104 }), 'receiving ${request.method} ${request.uri}'); 104 }), 'receiving ${request.method} ${request.uri}');
105 } 105 }
106 } 106 }
OLDNEW
« no previous file with comments | « pkg/http/test/safe_http_server.dart ('k') | pkg/scheduled_test/lib/src/scheduled_server/safe_http_server.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698