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

Side by Side Diff: runtime/bin/websocket_impl.dart

Issue 11263040: Make String.charCodes a getter. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update status files with co19 issue number. Created 8 years, 1 month 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
« no previous file with comments | « runtime/bin/mime_multipart_parser.dart ('k') | runtime/lib/string_base.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 const String _webSocketGUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; 5 const String _webSocketGUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
6 6
7 class _WebSocketMessageType { 7 class _WebSocketMessageType {
8 static const int NONE = 0; 8 static const int NONE = 0;
9 static const int BINARY = 1; 9 static const int BINARY = 1;
10 static const int TEXT = 2; 10 static const int TEXT = 2;
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 response.outputStream.close(); 591 response.outputStream.close();
592 return; 592 return;
593 } 593 }
594 594
595 // Send the upgrade response. 595 // Send the upgrade response.
596 response.statusCode = HttpStatus.SWITCHING_PROTOCOLS; 596 response.statusCode = HttpStatus.SWITCHING_PROTOCOLS;
597 response.headers.add(HttpHeaders.CONNECTION, "Upgrade"); 597 response.headers.add(HttpHeaders.CONNECTION, "Upgrade");
598 response.headers.add(HttpHeaders.UPGRADE, "websocket"); 598 response.headers.add(HttpHeaders.UPGRADE, "websocket");
599 String key = request.headers.value("Sec-WebSocket-Key"); 599 String key = request.headers.value("Sec-WebSocket-Key");
600 SHA1 sha1 = new SHA1(); 600 SHA1 sha1 = new SHA1();
601 sha1.update("$key$_webSocketGUID".charCodes()); 601 sha1.update("$key$_webSocketGUID".charCodes);
602 String accept = _Base64._encode(sha1.digest()); 602 String accept = _Base64._encode(sha1.digest());
603 response.headers.add("Sec-WebSocket-Accept", accept); 603 response.headers.add("Sec-WebSocket-Accept", accept);
604 response.contentLength = 0; 604 response.contentLength = 0;
605 605
606 // Upgrade the connection and get the underlying socket. 606 // Upgrade the connection and get the underlying socket.
607 WebSocketConnection conn = 607 WebSocketConnection conn =
608 new _WebSocketConnection(response.detachSocket()); 608 new _WebSocketConnection(response.detachSocket());
609 if (_onOpen !== null) _onOpen(conn); 609 if (_onOpen !== null) _onOpen(conn);
610 } 610 }
611 611
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 if (!isUpgrade) return false; 740 if (!isUpgrade) return false;
741 String upgrade = response.headers.value(HttpHeaders.UPGRADE); 741 String upgrade = response.headers.value(HttpHeaders.UPGRADE);
742 if (upgrade == null || upgrade.toLowerCase() != "websocket") { 742 if (upgrade == null || upgrade.toLowerCase() != "websocket") {
743 return false; 743 return false;
744 } 744 }
745 String accept = response.headers.value("Sec-WebSocket-Accept"); 745 String accept = response.headers.value("Sec-WebSocket-Accept");
746 if (accept == null) { 746 if (accept == null) {
747 return false; 747 return false;
748 } 748 }
749 SHA1 sha1 = new SHA1(); 749 SHA1 sha1 = new SHA1();
750 sha1.update("$_nonce$_webSocketGUID".charCodes()); 750 sha1.update("$_nonce$_webSocketGUID".charCodes);
751 List<int> expectedAccept = sha1.digest(); 751 List<int> expectedAccept = sha1.digest();
752 List<int> receivedAccept = _Base64._decode(accept); 752 List<int> receivedAccept = _Base64._decode(accept);
753 if (expectedAccept.length != receivedAccept.length) return false; 753 if (expectedAccept.length != receivedAccept.length) return false;
754 for (int i = 0; i < expectedAccept.length; i++) { 754 for (int i = 0; i < expectedAccept.length; i++) {
755 if (expectedAccept[i] != receivedAccept[i]) return false; 755 if (expectedAccept[i] != receivedAccept[i]) return false;
756 } 756 }
757 return true; 757 return true;
758 } 758 }
759 759
760 Function _onRequest; 760 Function _onRequest;
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 863
864 class _WebSocketCloseEvent implements CloseEvent { 864 class _WebSocketCloseEvent implements CloseEvent {
865 _WebSocketCloseEvent(this._wasClean, this._code, this._reason); 865 _WebSocketCloseEvent(this._wasClean, this._code, this._reason);
866 bool get wasClean => _wasClean; 866 bool get wasClean => _wasClean;
867 int get code => _code; 867 int get code => _code;
868 String get reason => _reason; 868 String get reason => _reason;
869 bool _wasClean; 869 bool _wasClean;
870 int _code; 870 int _code;
871 String _reason; 871 String _reason;
872 } 872 }
OLDNEW
« no previous file with comments | « runtime/bin/mime_multipart_parser.dart ('k') | runtime/lib/string_base.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698