Index: tests/standalone/io/http_connection_close_test.dart |
diff --git a/tests/standalone/io/http_connection_close_test.dart b/tests/standalone/io/http_connection_close_test.dart |
index ac6cedd4be516f96bf7d6fb0210f6ebc682694b5..604a9639203da4616d46b985d1884a0c551a989b 100644 |
--- a/tests/standalone/io/http_connection_close_test.dart |
+++ b/tests/standalone/io/http_connection_close_test.dart |
@@ -5,6 +5,7 @@ |
#import("dart:isolate"); |
#import("dart:io"); |
+#import("dart:uri"); |
void testHttp10Close(bool closeRequest) { |
HttpServer server = new HttpServer(); |
@@ -41,9 +42,41 @@ void testHttp11Close(bool closeRequest) { |
}; |
} |
+void testStreamResponse() { |
+ var server = new HttpServer(); |
+ server.listen("127.0.0.1", 0, backlog: 5); |
+ server.defaultRequestHandler = (var request, var response) { |
+ new Timer.repeating(10, (x) { |
+ Date now = new Date.now(); |
+ try { |
+ response.outputStream.writeString( |
+ 'data:${now.millisecondsSinceEpoch}\n\n'); |
+ } catch (e) { |
+ x.cancel(); |
+ server.close(); |
+ } |
+ }); |
+ }; |
+ |
+ var client = new HttpClient(); |
+ var connection = |
+ client.getUrl(new Uri.fromString("http://127.0.0.1:${server.port}")); |
+ connection.onResponse = (resp) { |
+ int bytes = 0; |
+ resp.inputStream.onData = () { |
+ bytes += resp.inputStream.read().length; |
+ //print(bytes); |
Mads Ager (google)
2012/11/20 08:04:28
Remove?
Søren Gjesse
2012/11/20 08:15:11
Done.
|
+ if (bytes > 100) { |
+ client.shutdown(); |
+ } |
+ }; |
+ }; |
+} |
+ |
main() { |
testHttp10Close(false); |
testHttp10Close(true); |
testHttp11Close(false); |
testHttp11Close(true); |
+ testStreamResponse(); |
} |