| 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 "dart:async"; | 6 import "dart:async"; |
| 7 import "dart:io"; | 7 import "dart:io"; |
| 8 import "dart:uri"; | 8 import "dart:uri"; |
| 9 | 9 |
| 10 void testHttp10Close(bool closeRequest) { | 10 void testHttp10Close(bool closeRequest) { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 server.close(); | 44 server.close(); |
| 45 }); | 45 }); |
| 46 if (closeRequest) socket.close(); | 46 if (closeRequest) socket.close(); |
| 47 }); | 47 }); |
| 48 }); | 48 }); |
| 49 } | 49 } |
| 50 | 50 |
| 51 void testStreamResponse() { | 51 void testStreamResponse() { |
| 52 HttpServer.bind().then((server) { | 52 HttpServer.bind().then((server) { |
| 53 server.listen((request) { | 53 server.listen((request) { |
| 54 var timer = new Timer.repeating(const Duration(milliseconds: 0), (_) { | 54 var timer = new Timer.periodic(const Duration(milliseconds: 0), (_) { |
| 55 request.response.write( | 55 request.response.write( |
| 56 'data:${new DateTime.now().millisecondsSinceEpoch}\n\n'); | 56 'data:${new DateTime.now().millisecondsSinceEpoch}\n\n'); |
| 57 }); | 57 }); |
| 58 request.response.done | 58 request.response.done |
| 59 .whenComplete(() { | 59 .whenComplete(() { |
| 60 timer.cancel(); | 60 timer.cancel(); |
| 61 }) | 61 }) |
| 62 .catchError((_) {}); | 62 .catchError((_) {}); |
| 63 }); | 63 }); |
| 64 | 64 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 81 }); | 81 }); |
| 82 } | 82 } |
| 83 | 83 |
| 84 main() { | 84 main() { |
| 85 testHttp10Close(false); | 85 testHttp10Close(false); |
| 86 testHttp10Close(true); | 86 testHttp10Close(true); |
| 87 testHttp11Close(false); | 87 testHttp11Close(false); |
| 88 testHttp11Close(true); | 88 testHttp11Close(true); |
| 89 testStreamResponse(); | 89 testStreamResponse(); |
| 90 } | 90 } |
| OLD | NEW |