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

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

Issue 839063005: Allow additional headers for WebSocket connect (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased Created 5 years, 11 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 b04e02f35d4fac5f9d1046a0cae3d22361831874..d9229b6e74f7893973b46248cd9e53abd06da164 100644
--- a/tests/standalone/io/web_socket_test.dart
+++ b/tests/standalone/io/web_socket_test.dart
@@ -350,6 +350,7 @@ class SecurityConfiguration {
}
testIndividualUpgrade(int connections) {
+ asyncStart();
createServer().then((server) {
server.listen((request) {
if (WebSocketTransformer.isUpgradeRequest(request)) {
@@ -392,6 +393,7 @@ class SecurityConfiguration {
Future.wait(futures).then((_) {
server.close();
client.close();
+ asyncEnd();
});
});
}
@@ -432,6 +434,40 @@ class SecurityConfiguration {
});
}
+ void testAdditionalHeaders() {
+ asyncStart();
+ createServer().then((server) {
+ server.listen((request) {
+ Expect.isTrue(WebSocketTransformer.isUpgradeRequest(request));
+ Expect.equals('my-value', request.headers['My-Header'][0]);
+ var header = request.headers['My-Header-Multiple'];
+ Expect.equals(1, header.length);
+ Expect.equals('my-value-1, my-value-2', header[0]);
+ WebSocketTransformer.upgrade(request).then((webSocket) {
+ webSocket.listen((_) { webSocket.close(); });
+ webSocket.add("Hello");
+ });
+ });
+
+ var url = '${secure ? "wss" : "ws"}://$HOST_NAME:${server.port}/';
+ var headers = {'My-Header': 'my-value',
+ 'My-Header-Multiple': ['my-value-1', 'my-value-2']};
+ print(headers);
+ print(headers['My-Header-Multiple'] is Iterable);
+ print(headers['My-Header-Multiple'].length);
+ WebSocket.connect(url, headers: headers).then((websocket) {
+ return websocket.listen((message) {
+ Expect.equals("Hello", message);
+ websocket.close();
+ }).asFuture();
+ }).then((_) {
+ server.close();
+ asyncEnd();
+ });
+ });
+ }
+
+
void runTests() {
testRequestResponseClientCloses(2, null, null, 1);
testRequestResponseClientCloses(2, 3001, null, 2);
@@ -453,6 +489,7 @@ class SecurityConfiguration {
testConnections(10, 3002, "Got tired");
testIndividualUpgrade(5);
testFromUpgradedSocket();
+ testAdditionalHeaders();
}
}
« 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