| 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 | 7 |
| 8 class ExpectedDataOutputStream implements OutputStream { | 8 class ExpectedDataOutputStream implements OutputStream { |
| 9 ExpectedDataOutputStream(List<int> this._data, | 9 ExpectedDataOutputStream(List<int> this._data, |
| 10 int this._cutoff, | 10 int this._cutoff, |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 HttpServer server = new HttpServer(); | 165 HttpServer server = new HttpServer(); |
| 166 server.listenOn(serverSocket); | 166 server.listenOn(serverSocket); |
| 167 void testContent(String request, | 167 void testContent(String request, |
| 168 String response, | 168 String response, |
| 169 [int okayFrom = 0, | 169 [int okayFrom = 0, |
| 170 bool expectError = true]) { | 170 bool expectError = true]) { |
| 171 // Inner callback to actually run a given setting. | 171 // Inner callback to actually run a given setting. |
| 172 void runSettings(int cutoff, | 172 void runSettings(int cutoff, |
| 173 bool closeAsError, | 173 bool closeAsError, |
| 174 bool expectError) { | 174 bool expectError) { |
| 175 server.onRequest = (HttpRequest request, HttpResponse response) { | 175 server.defaultRequestHandler = |
| 176 request.inputStream.onData = () { | 176 (HttpRequest request, HttpResponse response) { |
| 177 }; | 177 request.inputStream.onData = () { |
| 178 request.inputStream.onClosed = () { | 178 }; |
| 179 response.outputStream.close(); | 179 request.inputStream.onClosed = () { |
| 180 }; | 180 response.outputStream.close(); |
| 181 }; |
| 181 }; | 182 }; |
| 182 | 183 |
| 183 if (expectError) { | 184 if (expectError) { |
| 184 ReceivePort port = new ReceivePort(); | 185 ReceivePort port = new ReceivePort(); |
| 185 server.onError = (Exception error) { | 186 server.onError = (Exception error) { |
| 186 port.close(); | 187 port.close(); |
| 187 }; | 188 }; |
| 188 } else { | 189 } else { |
| 189 server.onError = (Exception error) { | 190 server.onError = (Exception error) { |
| 190 Expect.fail("An error was not expected: $error"); | 191 Expect.fail("An error was not expected: $error"); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 204 "GET / HTTP/1.1\r\nKeep-Alive: False\r\n\r\n", | 205 "GET / HTTP/1.1\r\nKeep-Alive: False\r\n\r\n", |
| 205 "HTTP/1.1 200 OK\r\ntransfer-encoding: chunked\r\nconnection: close" + | 206 "HTTP/1.1 200 OK\r\ntransfer-encoding: chunked\r\nconnection: close" + |
| 206 "\r\n\r\n0\r\n\r\n"); | 207 "\r\n\r\n0\r\n\r\n"); |
| 207 | 208 |
| 208 server.close(); | 209 server.close(); |
| 209 } | 210 } |
| 210 | 211 |
| 211 void main() { | 212 void main() { |
| 212 testSocketClose(); | 213 testSocketClose(); |
| 213 } | 214 } |
| OLD | NEW |