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

Side by Side 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, 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 'dart:async'; 10 import 'dart:async';
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 client.close(); 61 client.close();
62 asyncEnd(); 62 asyncEnd();
63 }); 63 });
64 } 64 }
65 65
66 void testGetServerClose() { 66 void testGetServerClose() {
67 asyncStart(); 67 asyncStart();
68 HttpServer.bind("127.0.0.1", 0).then((server) { 68 HttpServer.bind("127.0.0.1", 0).then((server) {
69 server.listen((request) { 69 server.listen((request) {
70 server.close(); 70 server.close();
71 new Timer(const Duration(milliseconds: 100), () {
72 request.response.close();
73 });
71 }); 74 });
72 75
73 var client = new HttpClient(); 76 var client = new HttpClient();
77 client.get("127.0.0.1", server.port, "/")
78 .then((request) => request.close())
79 .then((response) => response.drain())
80 .then((_) => asyncEnd());
81 });
82 }
83
84 void testGetServerCloseNoKeepAlive() {
85 asyncStart();
86 var client = new HttpClient();
87 HttpServer.bind("127.0.0.1", 0).then((server) {
88 int port = server.port;
89 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.
90 server.close();
91 request.response.close();
92 });
93
94 client.get("127.0.0.1", port, "/")
95 .then((request) => request.close())
96 .then((response) => response.drain())
97 .then((_) => client.get("127.0.0.1", port, "/"))
98 .then((request) => request.close())
99 .then((_) => Expect.fail('should not succeed'), onError: (_) {})
100 .then((_) => asyncEnd());
101 });
102 }
103
104 void testGetServerForceClose() {
105 asyncStart();
106 HttpServer.bind("127.0.0.1", 0).then((server) {
107 server.listen((request) {
108 server.close(force: true);
109 });
110
111 var client = new HttpClient();
74 client.get("127.0.0.1", server.port, "/") 112 client.get("127.0.0.1", server.port, "/")
75 .then((request) => request.close()) 113 .then((request) => request.close())
76 .then((response) { 114 .then((response) {
77 Expect.fail("Request not expected"); 115 Expect.fail("Request not expected");
78 }) 116 })
79 .catchError((error) => asyncEnd(), 117 .catchError((error) => asyncEnd(),
80 test: (error) => error is HttpException); 118 test: (error) => error is HttpException);
81 }); 119 });
82 } 120 }
83 121
84 void testGetDataServerClose() { 122 void testGetDataServerForceClose() {
85 asyncStart(); 123 asyncStart();
86 var completer = new Completer(); 124 var completer = new Completer();
87 HttpServer.bind("127.0.0.1", 0).then((server) { 125 HttpServer.bind("127.0.0.1", 0).then((server) {
88 server.listen((request) { 126 server.listen((request) {
89 request.response.contentLength = 100; 127 request.response.contentLength = 100;
90 request.response.write("data"); 128 request.response.write("data");
91 request.response.write("more data"); 129 request.response.write("more data");
92 completer.future.then((_) => server.close()); 130 completer.future.then((_) => server.close(force: true));
93 }); 131 });
94 132
95 var client = new HttpClient(); 133 var client = new HttpClient();
96 client.get("127.0.0.1", server.port, "/") 134 client.get("127.0.0.1", server.port, "/")
97 .then((request) => request.close()) 135 .then((request) => request.close())
98 .then((response) { 136 .then((response) {
99 // Close the (incomplete) response, now that we have seen 137 // Close the (incomplete) response, now that we have seen
100 // the response object. 138 // the response object.
101 completer.complete(null); 139 completer.complete(null);
102 int errors = 0; 140 int errors = 0;
(...skipping 22 matching lines...) Expand all
125 }); 163 });
126 }); 164 });
127 } 165 }
128 166
129 167
130 void main() { 168 void main() {
131 testGetEmptyRequest(); 169 testGetEmptyRequest();
132 testGetDataRequest(); 170 testGetDataRequest();
133 testGetInvalidHost(); 171 testGetInvalidHost();
134 testGetServerClose(); 172 testGetServerClose();
135 testGetDataServerClose(); 173 testGetServerCloseNoKeepAlive();
174 testGetServerForceClose();
175 testGetDataServerForceClose();
136 testPostEmptyRequest(); 176 testPostEmptyRequest();
137 } 177 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698