| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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:io"); | 5 #import("dart:io"); |
| 6 #import("dart:isolate"); | 6 #import("dart:isolate"); |
| 7 #import("dart:math"); | 7 #import("dart:math"); |
| 8 | 8 |
| 9 class ExpectedDataOutputStream implements OutputStream { | 9 class ExpectedDataOutputStream implements OutputStream { |
| 10 ExpectedDataOutputStream(List<int> this._data, | 10 ExpectedDataOutputStream(List<int> this._data, |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 (HttpRequest request, HttpResponse response) { | 182 (HttpRequest request, HttpResponse response) { |
| 183 request.inputStream.onData = () { | 183 request.inputStream.onData = () { |
| 184 }; | 184 }; |
| 185 request.inputStream.onClosed = () { | 185 request.inputStream.onClosed = () { |
| 186 response.outputStream.close(); | 186 response.outputStream.close(); |
| 187 }; | 187 }; |
| 188 }; | 188 }; |
| 189 | 189 |
| 190 if (expectError) { | 190 if (expectError) { |
| 191 ReceivePort port = new ReceivePort(); | 191 ReceivePort port = new ReceivePort(); |
| 192 server.onError = (Exception error) { | 192 server.onError = (var error) { |
| 193 port.close(); | 193 port.close(); |
| 194 }; | 194 }; |
| 195 } else { | 195 } else { |
| 196 server.onError = (Exception error) { | 196 server.onError = (var error) { |
| 197 Expect.fail("An error was not expected: $error"); | 197 Expect.fail("An error was not expected: $error"); |
| 198 }; | 198 }; |
| 199 } | 199 } |
| 200 | 200 |
| 201 serverSocket.spawnSocket(requestString, responseString, | 201 serverSocket.spawnSocket(requestString, responseString, |
| 202 cutoff, closeAsError); | 202 cutoff, closeAsError); |
| 203 // TODO(ajohnsen): Validate HttpServers number of connections. | 203 // TODO(ajohnsen): Validate HttpServers number of connections. |
| 204 } | 204 } |
| 205 for (int i = 1; i < responseString.length; i++) { | 205 for (int i = 1; i < responseString.length; i++) { |
| 206 bool _expectError = expectError && i < responseString.length - okayFrom; | 206 bool _expectError = expectError && i < responseString.length - okayFrom; |
| 207 runSettings(i, false, _expectError); | 207 runSettings(i, false, _expectError); |
| 208 runSettings(i, true, _expectError); | 208 runSettings(i, true, _expectError); |
| 209 } | 209 } |
| 210 } | 210 } |
| 211 testContent( | 211 testContent( |
| 212 "GET / HTTP/1.1\r\nKeep-Alive: False\r\n\r\n", | 212 "GET / HTTP/1.1\r\nKeep-Alive: False\r\n\r\n", |
| 213 "HTTP/1.1 200 OK\r\ntransfer-encoding: chunked\r\nconnection: close" | 213 "HTTP/1.1 200 OK\r\ntransfer-encoding: chunked\r\nconnection: close" |
| 214 "\r\n\r\n0\r\n\r\n"); | 214 "\r\n\r\n0\r\n\r\n"); |
| 215 | 215 |
| 216 server.close(); | 216 server.close(); |
| 217 } | 217 } |
| 218 | 218 |
| 219 void main() { | 219 void main() { |
| 220 testSocketClose(); | 220 testSocketClose(); |
| 221 } | 221 } |
| OLD | NEW |