Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2062)

Unified Diff: tests/standalone/io/http_shutdown_test.dart

Issue 11411121: Generate an error for active connections when the HTTP client is shutdown (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixed long line Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« sdk/lib/io/http.dart ('K') | « tests/standalone/io/http_session_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/http_shutdown_test.dart
diff --git a/tests/standalone/io/http_shutdown_test.dart b/tests/standalone/io/http_shutdown_test.dart
index c661778781f63aef32d8c8e0643f67d06b077c72..1d19e962a2db86ff100dacbad3b38fd5ae3b2dcc 100644
--- a/tests/standalone/io/http_shutdown_test.dart
+++ b/tests/standalone/io/http_shutdown_test.dart
@@ -22,11 +22,13 @@ void test1(int totalConnections) {
request.outputStream.close();
};
conn.onResponse = (HttpClientResponse response) {
- count++;
- if (count == totalConnections) {
- client.shutdown();
- server.close();
- }
+ response.inputStream.onClosed = () {
+ count++;
+ if (count == totalConnections) {
+ client.shutdown();
+ server.close();
+ }
+ };
};
}
}
@@ -51,11 +53,14 @@ void test2(int totalConnections) {
request.outputStream.close();
};
conn.onResponse = (HttpClientResponse response) {
- count++;
- if (count == totalConnections) {
- client.shutdown();
- server.close();
- }
+ response.inputStream.onData = response.inputStream.read;
+ response.inputStream.onClosed = () {
+ count++;
+ if (count == totalConnections) {
+ client.shutdown();
+ server.close();
+ }
+ };
};
}
}
@@ -85,11 +90,14 @@ void test3(int totalConnections) {
request.outputStream.close();
};
conn.onResponse = (HttpClientResponse response) {
- count++;
- if (count == totalConnections) {
- client.shutdown();
- server.close();
- }
+ response.inputStream.onData = response.inputStream.read;
+ response.inputStream.onClosed = () {
+ count++;
+ if (count == totalConnections) {
+ client.shutdown();
+ server.close();
+ }
+ };
};
}
}
@@ -113,6 +121,7 @@ void test4() {
var client= new HttpClient();
var conn = client.get("127.0.0.1", server.port, "/");
conn.onResponse = (var response) {
+ response.inputStream.onData = response.inputStream.read;
response.inputStream.onClosed = () {
client.shutdown();
};
@@ -137,13 +146,14 @@ void test5(int totalConnections) {
for (int i = 0; i < totalConnections; i++) {
var conn = client.post("127.0.0.1", server.port, "/");
conn.onRequest = (req) { req.outputStream.write([0]); };
+ conn.onError = (e) => Expect.isTrue(e is HttpException);
}
bool clientClosed = false;
new Timer.repeating(100, (timer) {
if (!clientClosed) {
if (server.connectionsInfo().total == totalConnections) {
clientClosed = true;
- client.shutdown();
+ client.shutdown(force: true);
}
} else {
if (server.connectionsInfo().total == 0) {
« sdk/lib/io/http.dart ('K') | « tests/standalone/io/http_session_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698