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

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

Issue 36643002: Don't close existing connection on HttpServer close (and stream cancel). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Always close idle connections. Created 7 years, 2 months 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
Index: tests/standalone/io/http_client_connect_test.dart
diff --git a/tests/standalone/io/http_client_connect_test.dart b/tests/standalone/io/http_client_connect_test.dart
index 3c5b88b4c36f927713555ed0636dd1a44eb46592..d96b11794d60e3f6d8bde0a5c9292ba138ce7c38 100644
--- a/tests/standalone/io/http_client_connect_test.dart
+++ b/tests/standalone/io/http_client_connect_test.dart
@@ -68,6 +68,44 @@ void testGetServerClose() {
HttpServer.bind("127.0.0.1", 0).then((server) {
server.listen((request) {
server.close();
+ new Timer(const Duration(milliseconds: 100), () {
+ request.response.close();
+ });
+ });
+
+ var client = new HttpClient();
+ client.get("127.0.0.1", server.port, "/")
+ .then((request) => request.close())
+ .then((response) => response.drain())
+ .then((_) => asyncEnd());
+ });
+}
+
+void testGetServerCloseNoKeepAlive() {
+ asyncStart();
+ var client = new HttpClient();
+ HttpServer.bind("127.0.0.1", 0).then((server) {
+ int port = server.port;
+ server.listen((request) {
Søren Gjesse 2013/10/23 13:23:25 Use server.first in the test?
Anders Johnsen 2013/10/23 14:12:34 Done.
+ server.close();
+ request.response.close();
+ });
+
+ client.get("127.0.0.1", port, "/")
+ .then((request) => request.close())
+ .then((response) => response.drain())
+ .then((_) => client.get("127.0.0.1", port, "/"))
+ .then((request) => request.close())
+ .then((_) => Expect.fail('should not succeed'), onError: (_) {})
+ .then((_) => asyncEnd());
+ });
+}
+
+void testGetServerForceClose() {
+ asyncStart();
+ HttpServer.bind("127.0.0.1", 0).then((server) {
+ server.listen((request) {
+ server.close(force: true);
});
var client = new HttpClient();
@@ -76,12 +114,12 @@ void testGetServerClose() {
.then((response) {
Expect.fail("Request not expected");
})
- .catchError((error) => asyncEnd(),
- test: (error) => error is HttpException);
+ .catchError((error) => asyncEnd(),
+ test: (error) => error is HttpException);
});
}
-void testGetDataServerClose() {
+void testGetDataServerForceClose() {
asyncStart();
var completer = new Completer();
HttpServer.bind("127.0.0.1", 0).then((server) {
@@ -89,7 +127,7 @@ void testGetDataServerClose() {
request.response.contentLength = 100;
request.response.write("data");
request.response.write("more data");
- completer.future.then((_) => server.close());
+ completer.future.then((_) => server.close(force: true));
});
var client = new HttpClient();
@@ -132,6 +170,8 @@ void main() {
testGetDataRequest();
testGetInvalidHost();
testGetServerClose();
- testGetDataServerClose();
+ testGetServerCloseNoKeepAlive();
+ testGetServerForceClose();
+ testGetDataServerForceClose();
testPostEmptyRequest();
}

Powered by Google App Engine
This is Rietveld 408576698