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

Side by Side Diff: sdk/lib/io/websocket_impl.dart

Issue 11889036: Enable WebSocket secure connection using "wss" in W3C interface. Add testing of secure WebSocket co… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 part of dart.io; 5 part of dart.io;
6 6
7 const String _webSocketGUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; 7 const String _webSocketGUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
8 8
9 class _WebSocketMessageType { 9 class _WebSocketMessageType {
10 static const int NONE = 0; 10 static const int NONE = 0;
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 Function _onOpen; 760 Function _onOpen;
761 Function _onNoUpgrade; 761 Function _onNoUpgrade;
762 HttpClientConnection _conn; 762 HttpClientConnection _conn;
763 String _nonce; 763 String _nonce;
764 } 764 }
765 765
766 766
767 class _WebSocket implements WebSocket { 767 class _WebSocket implements WebSocket {
768 _WebSocket(String url, [protocols]) { 768 _WebSocket(String url, [protocols]) {
769 Uri uri = new Uri.fromString(url); 769 Uri uri = new Uri.fromString(url);
770 if (uri.scheme != "ws") { 770 if (uri.scheme != "ws" && uri.scheme != "wss") {
771 throw new WebSocketException("Unsupported URL scheme ${uri.scheme}"); 771 throw new WebSocketException("Unsupported URL scheme ${uri.scheme}");
772 } 772 }
773 if (uri.userInfo != "") { 773 if (uri.userInfo != "") {
774 throw new WebSocketException("Unsupported user info ${uri.userInfo}"); 774 throw new WebSocketException("Unsupported user info ${uri.userInfo}");
775 } 775 }
776 int port = uri.port == 0 ? HttpClient.DEFAULT_HTTP_PORT : uri.port; 776 int port = uri.port == 0 ? HttpClient.DEFAULT_HTTP_PORT : uri.port;
777 String path = uri.path; 777 String path = uri.path;
778 if (path.length == 0) path = "/"; 778 if (path.length == 0) path = "/";
779 if (uri.query != "") { 779 if (uri.query != "") {
780 if (uri.fragment != "") { 780 if (uri.fragment != "") {
781 path = "${path}?${uri.query}#${uri.fragment}"; 781 path = "${path}?${uri.query}#${uri.fragment}";
782 } else { 782 } else {
783 path = "${path}?${uri.query}"; 783 path = "${path}?${uri.query}";
784 } 784 }
785 } 785 }
786 786
787 HttpClient client = new HttpClient(); 787 HttpClient client = new HttpClient();
788 HttpClientConnection conn = client.open("GET", uri.domain, port, path); 788 bool secure = (uri.scheme == 'wss');
789 HttpClientConnection conn = client.openUrl("GET",
790 new Uri.fromComponents(scheme: secure ? "https" : "http",
791 domain: uri.domain,
792 port: port,
793 path: path));
789 if (protocols is String) protocols = [protocols]; 794 if (protocols is String) protocols = [protocols];
790 _wsconn = new WebSocketClientConnection(conn, protocols); 795 _wsconn = new WebSocketClientConnection(conn, protocols);
791 _wsconn.onOpen = () { 796 _wsconn.onOpen = () {
792 // HTTP client not needed after socket have been detached. 797 // HTTP client not needed after socket have been detached.
793 client.shutdown(); 798 client.shutdown();
794 client = null; 799 client = null;
795 _readyState = WebSocket.OPEN; 800 _readyState = WebSocket.OPEN;
796 if (_onopen != null) _onopen(); 801 if (_onopen != null) _onopen();
797 }; 802 };
798 _wsconn.onMessage = (message) { 803 _wsconn.onMessage = (message) {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 867
863 class _WebSocketCloseEvent implements CloseEvent { 868 class _WebSocketCloseEvent implements CloseEvent {
864 _WebSocketCloseEvent(this._wasClean, this._code, this._reason); 869 _WebSocketCloseEvent(this._wasClean, this._code, this._reason);
865 bool get wasClean => _wasClean; 870 bool get wasClean => _wasClean;
866 int get code => _code; 871 int get code => _code;
867 String get reason => _reason; 872 String get reason => _reason;
868 bool _wasClean; 873 bool _wasClean;
869 int _code; 874 int _code;
870 String _reason; 875 String _reason;
871 } 876 }
OLDNEW
« no previous file with comments | « no previous file | tests/standalone/io/web_socket_test.dart » ('j') | tests/standalone/io/web_socket_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698