Chromium Code Reviews| 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) { |
|
Søren Gjesse
2013/08/21 07:39:54
Set server.idleTimeout to null here for completene
Anders Johnsen
2013/08/21 07:43:49
Done.
| |
| 18 server.idleTimeout = const Duration(milliseconds: 100); | |
| 19 | 17 |
| 20 server.listen((request) => request.response.close()); | 18 server.listen((request) => request.response.close()); |
| 21 | 19 |
| 22 Socket.connect("127.0.0.1", server.port).then((socket) { | 20 Socket.connect("127.0.0.1", server.port).then((socket) { |
|
Søren Gjesse
2013/08/21 07:39:54
How about waiting with timer until response data h
Anders Johnsen
2013/08/21 07:43:49
If I wait so long, the timer would already be star
| |
| 21 server.idleTimeout = const Duration(milliseconds: 100); | |
| 23 var data = "GET / HTTP/1.1\r\nContent-Length: 0\r\n\r\n"; | 22 var data = "GET / HTTP/1.1\r\nContent-Length: 0\r\n\r\n"; |
| 24 socket.write(data); | 23 socket.write(data); |
| 25 socket.listen( | 24 socket.listen( |
| 26 null, | 25 null, |
| 27 onDone: () { | 26 onDone: () { |
| 28 socket.close(); | 27 socket.close(); |
| 29 server.close(); | 28 server.close(); |
| 30 }); | 29 }); |
| 31 }); | 30 }); |
| 32 }); | 31 }); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 46 server.close(); | 45 server.close(); |
| 47 }); | 46 }); |
| 48 }); | 47 }); |
| 49 }); | 48 }); |
| 50 } | 49 } |
| 51 | 50 |
| 52 void main() { | 51 void main() { |
| 53 testTimeoutAfterRequest(); | 52 testTimeoutAfterRequest(); |
| 54 testTimeoutBeforeRequest(); | 53 testTimeoutBeforeRequest(); |
| 55 } | 54 } |
| OLD | NEW |