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

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

Issue 10911120: Cleanup and fixes to some dart:io files (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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
« no previous file with comments | « runtime/bin/string_stream.dart ('k') | tests/standalone/io/http_headers_test.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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 105
106 case _WebSocketOpcode.CLOSE: 106 case _WebSocketOpcode.CLOSE:
107 case _WebSocketOpcode.PING: 107 case _WebSocketOpcode.PING:
108 case _WebSocketOpcode.PONG: 108 case _WebSocketOpcode.PONG:
109 // Control frames cannot be fragmented. 109 // Control frames cannot be fragmented.
110 if (!_fin) throw new WebSocketException("Protocol error"); 110 if (!_fin) throw new WebSocketException("Protocol error");
111 break; 111 break;
112 112
113 default: 113 default:
114 throw new WebSocketException("Protocol error"); 114 throw new WebSocketException("Protocol error");
115 break;
116 } 115 }
117 _state = LEN_FIRST; 116 _state = LEN_FIRST;
118 break; 117 break;
119 118
120 case LEN_FIRST: 119 case LEN_FIRST:
121 _masked = (byte & 0x80) != 0; 120 _masked = (byte & 0x80) != 0;
122 _len = byte & 0x7F; 121 _len = byte & 0x7F;
123 if (_isControlFrame() && _len > 126) { 122 if (_isControlFrame() && _len > 126) {
124 throw new WebSocketException("Protocol error"); 123 throw new WebSocketException("Protocol error");
125 } 124 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 index += payload; 182 index += payload;
184 } 183 }
185 184
186 if (_remainingPayloadBytes == 0) { 185 if (_remainingPayloadBytes == 0) {
187 _controlFrameEnd(); 186 _controlFrameEnd();
188 } 187 }
189 } else { 188 } else {
190 switch (_currentMessageType) { 189 switch (_currentMessageType) {
191 case _WebSocketMessageType.NONE: 190 case _WebSocketMessageType.NONE:
192 throw new WebSocketException("Protocol error"); 191 throw new WebSocketException("Protocol error");
193 break;
194 192
195 case _WebSocketMessageType.TEXT: 193 case _WebSocketMessageType.TEXT:
196 case _WebSocketMessageType.BINARY: 194 case _WebSocketMessageType.BINARY:
197 if (onMessageData !== null) { 195 if (onMessageData !== null) {
198 onMessageData(buffer, index, payload); 196 onMessageData(buffer, index, payload);
199 } 197 }
200 index += payload; 198 index += payload;
201 if (_remainingPayloadBytes == 0) { 199 if (_remainingPayloadBytes == 0) {
202 _messageFrameEnd(); 200 _messageFrameEnd();
203 } 201 }
204 break; 202 break;
205 203
206 default: 204 default:
207 throw new WebSocketException("Protocol error"); 205 throw new WebSocketException("Protocol error");
208 break;
209
210 } 206 }
211 } 207 }
212 208
213 // Hack - as we always do index++ below. 209 // Hack - as we always do index++ below.
214 index--; 210 index--;
215 } 211 }
216 212
217 // Move to the next byte. 213 // Move to the next byte.
218 index++; 214 index++;
219 } 215 }
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 846
851 class _WebSocketCloseEvent implements CloseEvent { 847 class _WebSocketCloseEvent implements CloseEvent {
852 _WebSocketCloseEvent(this._wasClean, this._code, this._reason); 848 _WebSocketCloseEvent(this._wasClean, this._code, this._reason);
853 bool get wasClean => _wasClean; 849 bool get wasClean => _wasClean;
854 int get code => _code; 850 int get code => _code;
855 String get reason => _reason; 851 String get reason => _reason;
856 bool _wasClean; 852 bool _wasClean;
857 int _code; 853 int _code;
858 String _reason; 854 String _reason;
859 } 855 }
OLDNEW
« no previous file with comments | « runtime/bin/string_stream.dart ('k') | tests/standalone/io/http_headers_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698