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

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: Fix 'disable keep-alive' on server close. 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
« no previous file with comments | « sdk/lib/io/http_impl.dart ('k') | tests/standalone/io/http_client_request_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..b85896a85657894f607823900c29379d5ad59823 100644
--- a/tests/standalone/io/http_client_connect_test.dart
+++ b/tests/standalone/io/http_client_connect_test.dart
@@ -68,6 +68,41 @@ 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.first.then((request) => 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 +111,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 +124,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 +167,8 @@ void main() {
testGetDataRequest();
testGetInvalidHost();
testGetServerClose();
- testGetDataServerClose();
+ testGetServerCloseNoKeepAlive();
+ testGetServerForceClose();
+ testGetDataServerForceClose();
testPostEmptyRequest();
}
« no previous file with comments | « sdk/lib/io/http_impl.dart ('k') | tests/standalone/io/http_client_request_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698