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

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: 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();
74 client.get("127.0.0.1", server.port, "/") 77 client.get("127.0.0.1", server.port, "/")
75 .then((request) => request.close()) 78 .then((request) => request.close())
76 .then((response) { 79 .then((response) => response.drain())
77 Expect.fail("Request not expected"); 80 .then((_) => asyncEnd());
78 })
79 .catchError((error) => asyncEnd(),
80 test: (error) => error is HttpException);
81 }); 81 });
82 } 82 }
83 83
84 void testGetDataServerClose() {
Søren Gjesse 2013/10/23 08:14:05 This test is removed because there is no forceful
Anders Johnsen 2013/10/23 10:23:24 Agreed. Let me know what you think about the `forc
85 asyncStart();
86 var completer = new Completer();
87 HttpServer.bind("127.0.0.1", 0).then((server) {
88 server.listen((request) {
89 request.response.contentLength = 100;
90 request.response.write("data");
91 request.response.write("more data");
92 completer.future.then((_) => server.close());
93 });
94
95 var client = new HttpClient();
96 client.get("127.0.0.1", server.port, "/")
97 .then((request) => request.close())
98 .then((response) {
99 // Close the (incomplete) response, now that we have seen
100 // the response object.
101 completer.complete(null);
102 int errors = 0;
103 response.listen(
104 (data) {},
105 onError: (error) => errors++,
106 onDone: () {
107 Expect.equals(1, errors);
108 asyncEnd();
109 });
110 });
111 });
112 }
113
114 void testPostEmptyRequest() { 84 void testPostEmptyRequest() {
115 HttpServer.bind("127.0.0.1", 0).then((server) { 85 HttpServer.bind("127.0.0.1", 0).then((server) {
116 server.listen((request) { 86 server.listen((request) {
117 request.pipe(request.response); 87 request.pipe(request.response);
118 }); 88 });
119 89
120 var client = new HttpClient(); 90 var client = new HttpClient();
121 client.post("127.0.0.1", server.port, "/") 91 client.post("127.0.0.1", server.port, "/")
122 .then((request) => request.close()) 92 .then((request) => request.close())
123 .then((response) { 93 .then((response) {
124 response.listen((data) {}, onDone: server.close); 94 response.listen((data) {}, onDone: server.close);
125 }); 95 });
126 }); 96 });
127 } 97 }
128 98
129 99
130 void main() { 100 void main() {
131 testGetEmptyRequest(); 101 testGetEmptyRequest();
132 testGetDataRequest(); 102 testGetDataRequest();
133 testGetInvalidHost(); 103 testGetInvalidHost();
134 testGetServerClose(); 104 testGetServerClose();
135 testGetDataServerClose();
136 testPostEmptyRequest(); 105 testPostEmptyRequest();
137 } 106 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698