| OLD | NEW |
| 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:isolate"; | 10 import "dart:isolate"; |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 void testGET() { | 197 void testGET() { |
| 198 TestServerMain testServerMain = new TestServerMain(); | 198 TestServerMain testServerMain = new TestServerMain(); |
| 199 testServerMain.setServerStartedHandler((int port) { | 199 testServerMain.setServerStartedHandler((int port) { |
| 200 HttpClient httpClient = new HttpClient(); | 200 HttpClient httpClient = new HttpClient(); |
| 201 httpClient.get("127.0.0.1", port, "/0123456789") | 201 httpClient.get("127.0.0.1", port, "/0123456789") |
| 202 .then((request) => request.close()) | 202 .then((request) => request.close()) |
| 203 .then((response) { | 203 .then((response) { |
| 204 Expect.equals(HttpStatus.OK, response.statusCode); | 204 Expect.equals(HttpStatus.OK, response.statusCode); |
| 205 StringBuffer body = new StringBuffer(); | 205 StringBuffer body = new StringBuffer(); |
| 206 response.listen( | 206 response.listen( |
| 207 (data) => body.add(new String.fromCharCodes(data)), | 207 (data) => body.write(new String.fromCharCodes(data)), |
| 208 onDone: () { | 208 onDone: () { |
| 209 Expect.equals("01234567890", body.toString()); | 209 Expect.equals("01234567890", body.toString()); |
| 210 httpClient.close(); | 210 httpClient.close(); |
| 211 testServerMain.close(); | 211 testServerMain.close(); |
| 212 }); | 212 }); |
| 213 }); | 213 }); |
| 214 }); | 214 }); |
| 215 testServerMain.start(); | 215 testServerMain.start(); |
| 216 } | 216 } |
| 217 | 217 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 233 } else { | 233 } else { |
| 234 request.contentLength = data.length; | 234 request.contentLength = data.length; |
| 235 request.addString(data); | 235 request.addString(data); |
| 236 } | 236 } |
| 237 return request.close(); | 237 return request.close(); |
| 238 }) | 238 }) |
| 239 .then((response) { | 239 .then((response) { |
| 240 Expect.equals(HttpStatus.OK, response.statusCode); | 240 Expect.equals(HttpStatus.OK, response.statusCode); |
| 241 StringBuffer body = new StringBuffer(); | 241 StringBuffer body = new StringBuffer(); |
| 242 response.listen( | 242 response.listen( |
| 243 (data) => body.add(new String.fromCharCodes(data)), | 243 (data) => body.write(new String.fromCharCodes(data)), |
| 244 onDone: () { | 244 onDone: () { |
| 245 Expect.equals(data, body.toString()); | 245 Expect.equals(data, body.toString()); |
| 246 count++; | 246 count++; |
| 247 if (count < kMessageCount) { | 247 if (count < kMessageCount) { |
| 248 sendRequest(); | 248 sendRequest(); |
| 249 } else { | 249 } else { |
| 250 httpClient.close(); | 250 httpClient.close(); |
| 251 testServerMain.close(); | 251 testServerMain.close(); |
| 252 } | 252 } |
| 253 }); | 253 }); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 267 void test404() { | 267 void test404() { |
| 268 TestServerMain testServerMain = new TestServerMain(); | 268 TestServerMain testServerMain = new TestServerMain(); |
| 269 testServerMain.setServerStartedHandler((int port) { | 269 testServerMain.setServerStartedHandler((int port) { |
| 270 HttpClient httpClient = new HttpClient(); | 270 HttpClient httpClient = new HttpClient(); |
| 271 httpClient.get("127.0.0.1", port, "/thisisnotfound") | 271 httpClient.get("127.0.0.1", port, "/thisisnotfound") |
| 272 .then((request) => request.close()) | 272 .then((request) => request.close()) |
| 273 .then((response) { | 273 .then((response) { |
| 274 Expect.equals(HttpStatus.NOT_FOUND, response.statusCode); | 274 Expect.equals(HttpStatus.NOT_FOUND, response.statusCode); |
| 275 var body = new StringBuffer(); | 275 var body = new StringBuffer(); |
| 276 response.listen( | 276 response.listen( |
| 277 (data) => body.add(new String.fromCharCodes(data)), | 277 (data) => body.write(new String.fromCharCodes(data)), |
| 278 onDone: () { | 278 onDone: () { |
| 279 Expect.equals("Page not found", body.toString()); | 279 Expect.equals("Page not found", body.toString()); |
| 280 httpClient.close(); | 280 httpClient.close(); |
| 281 testServerMain.close(); | 281 testServerMain.close(); |
| 282 }); | 282 }); |
| 283 }); | 283 }); |
| 284 }); | 284 }); |
| 285 testServerMain.start(); | 285 testServerMain.start(); |
| 286 } | 286 } |
| 287 | 287 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 310 } | 310 } |
| 311 | 311 |
| 312 void main() { | 312 void main() { |
| 313 testStartStop(); | 313 testStartStop(); |
| 314 testGET(); | 314 testGET(); |
| 315 testPOST(true); | 315 testPOST(true); |
| 316 testPOST(false); | 316 testPOST(false); |
| 317 test404(); | 317 test404(); |
| 318 testReasonPhrase(); | 318 testReasonPhrase(); |
| 319 } | 319 } |
| OLD | NEW |