| 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 // VMOptions= | 5 // VMOptions= |
| 6 // VMOptions=--short_socket_read | 6 // VMOptions=--short_socket_read |
| 7 // VMOptions=--short_socket_write | 7 // VMOptions=--short_socket_write |
| 8 // VMOptions=--short_socket_read --short_socket_write | 8 // VMOptions=--short_socket_read --short_socket_write |
| 9 | 9 |
| 10 import "package:expect/expect.dart"; | |
| 11 import "dart:async"; | 10 import "dart:async"; |
| 12 import "dart:io"; | 11 import "dart:io"; |
| 13 import "dart:isolate"; | 12 import "dart:isolate"; |
| 14 | 13 |
| 15 | 14 |
| 16 void testTimeoutAfterRequest() { | 15 void testTimeoutAfterRequest() { |
| 17 HttpServer.bind("127.0.0.1", 0).then((server) { | 16 HttpServer.bind("127.0.0.1", 0).then((server) { |
| 18 server.idleTimeout = const Duration(milliseconds: 100); | 17 server.idleTimeout = null; |
| 19 | 18 |
| 20 server.listen((request) => request.response.close()); | 19 server.listen((request) { |
| 20 server.idleTimeout = const Duration(milliseconds: 100); |
| 21 request.response.close(); |
| 22 }); |
| 21 | 23 |
| 22 Socket.connect("127.0.0.1", server.port).then((socket) { | 24 Socket.connect("127.0.0.1", server.port).then((socket) { |
| 23 var data = "GET / HTTP/1.1\r\nContent-Length: 0\r\n\r\n"; | 25 var data = "GET / HTTP/1.1\r\nContent-Length: 0\r\n\r\n"; |
| 24 socket.write(data); | 26 socket.write(data); |
| 25 socket.listen( | 27 socket.listen( |
| 26 null, | 28 null, |
| 27 onDone: () { | 29 onDone: () { |
| 28 socket.close(); | 30 socket.close(); |
| 29 server.close(); | 31 server.close(); |
| 30 }); | 32 }); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 46 server.close(); | 48 server.close(); |
| 47 }); | 49 }); |
| 48 }); | 50 }); |
| 49 }); | 51 }); |
| 50 } | 52 } |
| 51 | 53 |
| 52 void main() { | 54 void main() { |
| 53 testTimeoutAfterRequest(); | 55 testTimeoutAfterRequest(); |
| 54 testTimeoutBeforeRequest(); | 56 testTimeoutBeforeRequest(); |
| 55 } | 57 } |
| OLD | NEW |