| 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:async"; | 10 import "dart:async"; |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 }); | 243 }); |
| 244 | 244 |
| 245 createClient(server.port).catchError((error) { | 245 createClient(server.port).catchError((error) { |
| 246 server.close(); | 246 server.close(); |
| 247 }); | 247 }); |
| 248 }); | 248 }); |
| 249 } | 249 } |
| 250 | 250 |
| 251 | 251 |
| 252 void testUsePOST() { | 252 void testUsePOST() { |
| 253 asyncStart(); |
| 253 createServer().then((server) { | 254 createServer().then((server) { |
| 254 asyncStart(); | |
| 255 server.transform(new WebSocketTransformer()).listen((webSocket) { | 255 server.transform(new WebSocketTransformer()).listen((webSocket) { |
| 256 Expect.fail("No connection expected"); | 256 Expect.fail("No connection expected"); |
| 257 }, onError: (e) { | 257 }, onError: (e) { |
| 258 asyncEnd(); | 258 asyncEnd(); |
| 259 }); | 259 }); |
| 260 | 260 |
| 261 HttpClient client = new HttpClient(); | 261 HttpClient client = new HttpClient(); |
| 262 client.postUrl(Uri.parse( | 262 client.postUrl(Uri.parse( |
| 263 "${secure ? 'https:' : 'http:'}//$HOST_NAME:${server.port}/")) | 263 "${secure ? 'https:' : 'http:'}//$HOST_NAME:${server.port}/")) |
| 264 .then((request) => request.close()) | 264 .then((request) => request.close()) |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 }); | 329 }); |
| 330 }); | 330 }); |
| 331 } | 331 } |
| 332 | 332 |
| 333 for (int i = 0; i < totalConnections; i++) { | 333 for (int i = 0; i < totalConnections; i++) { |
| 334 webSocketConnection(); | 334 webSocketConnection(); |
| 335 } | 335 } |
| 336 }); | 336 }); |
| 337 } | 337 } |
| 338 | 338 |
| 339 testIndivitualUpgrade(int connections) { | 339 testIndividualUpgrade(int connections) { |
| 340 createServer().then((server) { | 340 createServer().then((server) { |
| 341 server.listen((request) { | 341 server.listen((request) { |
| 342 if (WebSocketTransformer.isUpgradeRequest(request)) { | 342 if (WebSocketTransformer.isUpgradeRequest(request)) { |
| 343 WebSocketTransformer.upgrade(request).then((webSocket) { | 343 WebSocketTransformer.upgrade(request).then((webSocket) { |
| 344 webSocket.listen((_) { webSocket.close(); }); | 344 webSocket.listen((_) { webSocket.close(); }); |
| 345 webSocket.add("Hello"); | 345 webSocket.add("Hello"); |
| 346 }); | 346 }); |
| 347 } else { | 347 } else { |
| 348 Expect.isFalse(WebSocketTransformer.isUpgradeRequest(request)); | 348 Expect.isFalse(WebSocketTransformer.isUpgradeRequest(request)); |
| 349 request.response.statusCode = HttpStatus.OK; | 349 request.response.statusCode = HttpStatus.OK; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 testMessageLength(127); | 395 testMessageLength(127); |
| 396 testMessageLength(65535); | 396 testMessageLength(65535); |
| 397 testMessageLength(65536); | 397 testMessageLength(65536); |
| 398 testDoubleCloseClient(); | 398 testDoubleCloseClient(); |
| 399 testDoubleCloseServer(); | 399 testDoubleCloseServer(); |
| 400 testImmediateCloseServer(); | 400 testImmediateCloseServer(); |
| 401 testImmediateCloseClient(); | 401 testImmediateCloseClient(); |
| 402 testNoUpgrade(); | 402 testNoUpgrade(); |
| 403 testUsePOST(); | 403 testUsePOST(); |
| 404 testConnections(10, 3002, "Got tired"); | 404 testConnections(10, 3002, "Got tired"); |
| 405 testIndivitualUpgrade(5); | 405 testIndividualUpgrade(5); |
| 406 } | 406 } |
| 407 } | 407 } |
| 408 | 408 |
| 409 | 409 |
| 410 void initializeSSL() { | 410 void initializeSSL() { |
| 411 var testPkcertDatabase = join(dirname(Platform.script), 'pkcert'); | 411 var testPkcertDatabase = join(dirname(Platform.script), 'pkcert'); |
| 412 SecureSocket.initialize(database: testPkcertDatabase, | 412 SecureSocket.initialize(database: testPkcertDatabase, |
| 413 password: "dartdart"); | 413 password: "dartdart"); |
| 414 } | 414 } |
| 415 | 415 |
| 416 | 416 |
| 417 main() { | 417 main() { |
| 418 asyncStart(); |
| 418 new SecurityConfiguration(secure: false).runTests(); | 419 new SecurityConfiguration(secure: false).runTests(); |
| 419 initializeSSL(); | 420 initializeSSL(); |
| 420 new SecurityConfiguration(secure: true).runTests(); | 421 new SecurityConfiguration(secure: true).runTests(); |
| 422 asyncEnd(); |
| 421 } | 423 } |
| OLD | NEW |