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

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: 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
« sdk/lib/io/websocket_impl.dart ('K') | « 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..0aa33a8724bfbf649fcc2aef40eb9a3e8168f47f 100644
--- a/tests/standalone/io/web_socket_test.dart
+++ b/tests/standalone/io/web_socket_test.dart
@@ -432,6 +432,34 @@ class SecurityConfiguration {
});
}
+ void testOnRequest(bool useFuture) {
+ createServer().then((server) {
+ server.listen((request) {
+ Expect.isTrue(WebSocketTransformer.isUpgradeRequest(request));
+ Expect.equals(request.headers['My-Header'][0], 'my-value');
+ WebSocketTransformer.upgrade(request).then((webSocket) {
+ webSocket.listen((_) { webSocket.close(); });
+ webSocket.add("Hello");
+ });
+ });
+
+ onRequest(request) {
+ request.headers.set('My-Header', 'my-value');
+ return useFuture ? new Future.value() : null;
Lasse Reichstein Nielsen 2015/01/12 15:11:56 Consider actually delaying some action to just bef
Søren Gjesse 2015/01/12 15:36:34 Removed the use of a callback.
+ }
+
+ var url = '${secure ? "wss" : "ws"}://$HOST_NAME:${server.port}/';
+
+ WebSocket.connect(url, onRequest: onRequest).then((websocket) {
+ return websocket.listen((message) {
+ Expect.equals("Hello", message);
+ websocket.close();
+ }).asFuture();
+ }).then((_) => server.close());
+ });
+ }
kustermann 2015/01/09 14:45:12 [Since this file already imports async_helper, you
Søren Gjesse 2015/01/12 15:36:34 Done.
+
+
void runTests() {
testRequestResponseClientCloses(2, null, null, 1);
testRequestResponseClientCloses(2, 3001, null, 2);
@@ -453,6 +481,8 @@ class SecurityConfiguration {
testConnections(10, 3002, "Got tired");
testIndividualUpgrade(5);
testFromUpgradedSocket();
+ testOnRequest(true);
+ testOnRequest(false);
}
}
« sdk/lib/io/websocket_impl.dart ('K') | « sdk/lib/io/websocket_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698