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

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

Issue 11879042: Improve the error-propagation on socket streams (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed comments Created 7 years, 11 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/socket_stream_impl.dart ('k') | tests/standalone/io/http_server_socket_test.dart » ('j') | 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) 2012, 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 socket = new Socket("127.0.0.1", port); 10 Socket socket = new Socket("127.0.0.1", port);
11 socket.onConnect = () { 11 socket.onConnect = () {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 sendData(d, server.port); 53 sendData(d, server.port);
54 54
55 return c.future; 55 return c.future;
56 } 56 }
57 57
58 final data; 58 final data;
59 final String exception; 59 final String exception;
60 final bool expectRequest; 60 final bool expectRequest;
61 } 61 }
62 62
63 void testEarlyClose() { 63 void testEarlyClose1() {
64 List<EarlyCloseTest> tests = new List<EarlyCloseTest>(); 64 List<EarlyCloseTest> tests = new List<EarlyCloseTest>();
65 void add(Object data, String exception, {bool expectRequest: false}) { 65 void add(Object data, String exception, {bool expectRequest: false}) {
66 tests.add(new EarlyCloseTest(data, exception, expectRequest)); 66 tests.add(new EarlyCloseTest(data, exception, expectRequest));
67 } 67 }
68 // The empty packet is valid. 68 // The empty packet is valid.
69 69
70 // Close while sending header 70 // Close while sending header
71 String message = "Connection closed before full request header was received"; 71 String message = "Connection closed before full request header was received";
72 add("G", message); 72 add("G", message);
73 add("GET /", message); 73 add("GET /", message);
(...skipping 14 matching lines...) Expand all
88 void runTest(Iterator it) { 88 void runTest(Iterator it) {
89 if (it.moveNext()) { 89 if (it.moveNext()) {
90 it.current.execute(server).then((_) => runTest(it)); 90 it.current.execute(server).then((_) => runTest(it));
91 } else { 91 } else {
92 server.close(); 92 server.close();
93 } 93 }
94 } 94 }
95 runTest(tests.iterator); 95 runTest(tests.iterator);
96 } 96 }
97 97
98 testEarlyClose2() {
99 var server = new HttpServer();
100 server.listen("127.0.0.1", 0);
101 server.onError = (e) { /* ignore */ };
102 server.defaultRequestHandler = (request, response) {
103 String name = new Options().script;
104 new File(name).openInputStream().pipe(response.outputStream);
105 };
106
107 var count = 0;
108 var makeRequest;
109 makeRequest = () {
110 Socket socket = new Socket("127.0.0.1", server.port);
111 socket.onConnect = () {
112 var data = "GET / HTTP/1.1\r\nContent-Length: 0\r\n\r\n".charCodes;
113 socket.writeList(data, 0, data.length);
114 socket.close();
115 if (++count < 10) {
116 makeRequest();
117 } else {
118 server.close();
119 }
120 };
121 };
122
123 makeRequest();
124 }
125
98 void main() { 126 void main() {
99 testEarlyClose(); 127 testEarlyClose1();
128 testEarlyClose2();
100 } 129 }
OLDNEW
« no previous file with comments | « sdk/lib/io/socket_stream_impl.dart ('k') | tests/standalone/io/http_server_socket_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698