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

Unified Diff: tests/standalone/io/web_socket_test.dart

Issue 12400002: Add individual HTTP request to web socket upgrade support (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/io/websocket_impl.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/web_socket_test.dart
diff --git a/tests/standalone/io/web_socket_test.dart b/tests/standalone/io/web_socket_test.dart
index 9497cfdb2a67d576b6c4c2e19bab20a2ace721ae..cac5a4e39691c116d8dc4c4bc724471d46515587 100644
--- a/tests/standalone/io/web_socket_test.dart
+++ b/tests/standalone/io/web_socket_test.dart
@@ -288,6 +288,57 @@ class SecurityConfiguration {
});
}
+ testIndivitualUpgrade(int connections) {
+ createServer().then((server) {
+ int closeCount = 0;
Anders Johnsen 2013/03/04 14:41:57 Unused?
Søren Gjesse 2013/03/04 15:50:15 Removed.
+ server.listen((request) {
+ if (WebSocketTransformer.isUpgradeRequest(request)) {
+ WebSocketTransformer.upgrade(request).then((webSocket) {
+ webSocket.listen((_) { webSocket.close(); });
+ webSocket.send("Hello");
+ });
+ } else {
+ Expect.isFalse(WebSocketTransformer.isUpgradeRequest(request));
+ request.response.statusCode = HttpStatus.OK;
+ request.response.close();
+ }
+ });
+
+ var futures = [];
+
+ var wsProtocol = '${secure ? "wss" : "ws"}';
+ var baseWsUrl = '$wsProtocol://$HOST_NAME:${server.port}/';
+ var httpProtocol = '${secure ? "https" : "http"}';
+ var baseHttpUrl = '$httpProtocol://$HOST_NAME:${server.port}/';
+ HttpClient client = new HttpClient();
+
+ for (int i = 0; i < connections; i++) {
+ var completer1 = new Completer();
+ futures.add(completer1.future);
+ WebSocket.connect('${baseWsUrl}')
+ .then((websocket) {
+ websocket.listen((_) { websocket.close(); },
+ onDone: completer1.complete);
+ });
+
+ var completer2 = new Completer();
+ futures.add(completer2.future);
+ client.openUrl("GET", new Uri.fromString('${baseHttpUrl}'))
Anders Johnsen 2013/03/04 14:41:57 Add the result of client.openUrl directl to future
Søren Gjesse 2013/03/04 15:50:15 Done.
+ .then((request) => request.close())
+ .then((response) {
+ response.listen((_) { });
+ Expect.equals(HttpStatus.OK, response.statusCode);
+ completer2.complete();
+ });
+ }
+
+ Future.wait(futures).then((_) {
+ server.close();
+ client.close();
+ });
+ });
+ }
+
void runTests() {
testRequestResponseClientCloses(2, null, null);
testRequestResponseClientCloses(2, 3001, null);
@@ -305,6 +356,7 @@ class SecurityConfiguration {
testNoUpgrade();
testUsePOST();
testConnections(10, 3002, "Got tired");
+ testIndivitualUpgrade(5);
}
}
« no previous file with comments | « sdk/lib/io/websocket_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698