| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 29 matching lines...) Expand all Loading... |
| 40 server.close(); | 40 server.close(); |
| 41 }; | 41 }; |
| 42 }; | 42 }; |
| 43 } | 43 } |
| 44 | 44 |
| 45 void testStreamResponse() { | 45 void testStreamResponse() { |
| 46 var server = new HttpServer(); | 46 var server = new HttpServer(); |
| 47 server.listen("127.0.0.1", 0, backlog: 5); | 47 server.listen("127.0.0.1", 0, backlog: 5); |
| 48 server.defaultRequestHandler = (var request, var response) { | 48 server.defaultRequestHandler = (var request, var response) { |
| 49 new Timer.repeating(10, (x) { | 49 new Timer.repeating(10, (x) { |
| 50 Date now = new Date.now(); | 50 DateTime now = new DateTime.now(); |
| 51 try { | 51 try { |
| 52 response.outputStream.writeString( | 52 response.outputStream.writeString( |
| 53 'data:${now.millisecondsSinceEpoch}\n\n'); | 53 'data:${now.millisecondsSinceEpoch}\n\n'); |
| 54 } catch (e) { | 54 } catch (e) { |
| 55 x.cancel(); | 55 x.cancel(); |
| 56 server.close(); | 56 server.close(); |
| 57 } | 57 } |
| 58 }); | 58 }); |
| 59 }; | 59 }; |
| 60 | 60 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 73 connection.onError = (e) => Expect.isTrue(e is HttpException); | 73 connection.onError = (e) => Expect.isTrue(e is HttpException); |
| 74 } | 74 } |
| 75 | 75 |
| 76 main() { | 76 main() { |
| 77 testHttp10Close(false); | 77 testHttp10Close(false); |
| 78 testHttp10Close(true); | 78 testHttp10Close(true); |
| 79 testHttp11Close(false); | 79 testHttp11Close(false); |
| 80 testHttp11Close(true); | 80 testHttp11Close(true); |
| 81 testStreamResponse(); | 81 testStreamResponse(); |
| 82 } | 82 } |
| OLD | NEW |