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

Side by Side Diff: tests/standalone/io/http_server_early_client_close_test.dart

Issue 12438008: Fix multiple close of incoming in _HttpParser. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/io/http_parser.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 import "dart:async"; 5 import "dart:async";
6 import "dart:io"; 6 import "dart:io";
7 import "dart:isolate"; 7 import "dart:isolate";
8 8
9 void sendData(List<int> data, int port) { 9 void sendData(List<int> data, int port) {
10 Socket.connect("127.0.0.1", port).then((socket) { 10 Socket.connect("127.0.0.1", port).then((socket) {
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 } 102 }
103 } 103 }
104 runTest(tests.iterator); 104 runTest(tests.iterator);
105 } 105 }
106 106
107 testEarlyClose2() { 107 testEarlyClose2() {
108 HttpServer.bind("127.0.0.1", 0).then((server) { 108 HttpServer.bind("127.0.0.1", 0).then((server) {
109 server.listen( 109 server.listen(
110 (request) { 110 (request) {
111 String name = new Options().script; 111 String name = new Options().script;
112 new File(name).openRead().pipe(request.response); 112 new File(name).openRead().pipe(request.response)
113 }, 113 .catchError((e) { /* ignore */ });
114 onError: (e) { /* ignore */ }); 114 });
115 115
116 var count = 0; 116 var count = 0;
117 makeRequest() { 117 makeRequest() {
118 Socket.connect("127.0.0.1", server.port).then((socket) { 118 Socket.connect("127.0.0.1", server.port).then((socket) {
119 var data = "GET / HTTP/1.1\r\nContent-Length: 0\r\n\r\n".codeUnits; 119 var data = "GET / HTTP/1.1\r\nContent-Length: 0\r\n\r\n";
120 socket.add(data); 120 socket.write(data);
121 socket.close(); 121 socket.close();
122 socket.done.then((_) { 122 socket.done.then((_) {
123 socket.destroy(); 123 socket.destroy();
124 if (++count < 10) { 124 if (++count < 10) {
125 makeRequest(); 125 makeRequest();
126 } else { 126 } else {
127 server.close(); 127 server.close();
128 } 128 }
129 }); 129 });
130 }); 130 });
131 } 131 }
132 makeRequest(); 132 makeRequest();
133 }); 133 });
134 } 134 }
135 135
136 void testEarlyClose3() {
137 HttpServer.bind().then((server) {
138 server.listen((request) {
139 var subscription;
140 subscription = request.listen(
141 (_) {},
142 onError: (error) {
143 // subscription.cancel should not trigger an error.
144 subscription.cancel();
145 server.close();
146 });
147 });
148 Socket.connect("localhost", server.port)
149 .then((socket) {
150 socket.write("GET / HTTP/1.1\r\n");
151 socket.write("Content-Length: 10\r\n");
152 socket.write("\r\n");
153 socket.write("data");
154 socket.close();
155 socket.listen((_) {});
156 });
157 });
158 }
159
136 void main() { 160 void main() {
137 testEarlyClose1(); 161 testEarlyClose1();
138 // testEarlyClose2(); 162 testEarlyClose2();
163 testEarlyClose3();
139 } 164 }
OLDNEW
« no previous file with comments | « sdk/lib/io/http_parser.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698