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 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 | 10 |
11 import 'package:http_multi_server/http_multi_server.dart'; | 11 import 'package:http_multi_server/http_multi_server.dart'; |
12 import 'package:shelf/shelf.dart' as shelf; | 12 import 'package:shelf/shelf.dart' as shelf; |
13 import 'package:shelf/shelf_io.dart' as shelf_io; | 13 import 'package:shelf/shelf_io.dart' as shelf_io; |
14 | 14 |
15 import 'scheduled_test.dart'; | 15 import 'scheduled_test.dart'; |
16 import 'src/scheduled_server/handler.dart'; | 16 import 'src/scheduled_server/handler.dart'; |
17 import 'src/utils.dart'; | |
18 | 17 |
19 /// A class representing an HTTP server that's scheduled to run in the course of | 18 /// A class representing an HTTP server that's scheduled to run in the course of |
20 /// the test. This class allows the server's request handling to be scheduled | 19 /// the test. This class allows the server's request handling to be scheduled |
21 /// synchronously. | 20 /// synchronously. |
22 /// | 21 /// |
23 /// The server expects requests to be received in the order [handle] is called, | 22 /// The server expects requests to be received in the order [handle] is called, |
24 /// and expects that no additional requests will be received. | 23 /// and expects that no additional requests will be received. |
25 class ScheduledServer { | 24 class ScheduledServer { |
26 /// The description of the server. | 25 /// The description of the server. |
27 final String description; | 26 final String description; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 return _handlers.removeFirst().fn(request); | 96 return _handlers.removeFirst().fn(request); |
98 }).catchError((error, stackTrace) { | 97 }).catchError((error, stackTrace) { |
99 registerException(error, stackTrace); | 98 registerException(error, stackTrace); |
100 | 99 |
101 return new shelf.Response.internalServerError( | 100 return new shelf.Response.internalServerError( |
102 body: error.toString(), | 101 body: error.toString(), |
103 headers: {'content-type': 'text/plain'}); | 102 headers: {'content-type': 'text/plain'}); |
104 }); | 103 }); |
105 } | 104 } |
106 } | 105 } |
OLD | NEW |