Chromium Code Reviews| Index: sdk/lib/io/websocket.dart |
| diff --git a/sdk/lib/io/websocket.dart b/sdk/lib/io/websocket.dart |
| index 3a65685259c89df5d92999645ca84c3c1fa846d4..8d183650309ef1565c97f37e770d4582bf1d6772 100644 |
| --- a/sdk/lib/io/websocket.dart |
| +++ b/sdk/lib/io/websocket.dart |
| @@ -12,7 +12,7 @@ abstract class WebSocketStatus { |
| static const int GOING_AWAY = 1001; |
| static const int PROTOCOL_ERROR = 1002; |
| static const int UNSUPPORTED_DATA = 1003; |
| - static const int RESERVED_1004 = 1004; |
| + static const int RESERVED_1004 = 1004; |
| static const int NO_STATUS_RECEIVED = 1005; |
| static const int ABNORMAL_CLOSURE = 1006; |
| static const int INVALID_FRAME_PAYLOAD_DATA = 1007; |
| @@ -41,7 +41,8 @@ class CompressionOptions { |
| /** |
| * Disables WebSocket Compression. |
| */ |
| - static const CompressionOptions OFF = const CompressionOptions(enabled: false); |
| + static const CompressionOptions OFF = |
| + const CompressionOptions(enabled: false); |
| /** |
| * Control whether the client will reuse it's compression instances. |
| @@ -68,9 +69,12 @@ class CompressionOptions { |
| */ |
| final bool enabled; |
| - const CompressionOptions({this.clientNoContextTakeover: false, |
| - this.serverNoContextTakeover: false, this.clientMaxWindowBits, |
| - this.serverMaxWindowBits, this.enabled: true}); |
| + const CompressionOptions( |
| + {this.clientNoContextTakeover: false, |
| + this.serverNoContextTakeover: false, |
| + this.clientMaxWindowBits, |
| + this.serverMaxWindowBits, |
| + this.enabled: true}); |
| /** |
| * Create a Compression Header |
| @@ -80,29 +84,32 @@ class CompressionOptions { |
| return ""; |
| } |
| - var header = "permessage-deflate"; |
| + var header = _WebSocketImpl.PER_MESSAGE_DEFLATE; |
| if (requested == null) { |
| header += "; client_max_window_bits"; |
| } else { |
| if (requested.contains("client_max_window_bits")) { |
| - var myMaxWindowBits = clientMaxWindowBits == null ? 15 : clientMaxWindowBits; |
| + var myMaxWindowBits = |
| + clientMaxWindowBits == null ? _WebSocketImpl.DEFAULT_WINDOW_BITS : clientMaxWindowBits; |
|
kustermann
2015/07/20 09:34:12
long line
|
| header += "; client_max_window_bits=${myMaxWindowBits}"; |
| } |
| } |
| - if (clientNoContextTakeover && (requested != null |
| - && requested.contains("client_no_context_takeover"))) { |
| + if (clientNoContextTakeover && |
| + (requested != null && |
| + requested.contains("client_no_context_takeover"))) { |
|
kustermann
2015/07/20 09:34:12
Indentation seems wrong. Would be nice if you coul
|
| header += "; client_no_context_takeover"; |
| } |
| - if (serverNoContextTakeover && (requested != null |
| - && requested.contains("server_no_context_takeover"))) { |
| + if (serverNoContextTakeover && |
| + (requested != null && |
| + requested.contains("server_no_context_takeover"))) { |
|
kustermann
2015/07/20 09:34:12
ditto
|
| header += "; server_no_context_takeover"; |
| } |
| if (requested != null) { |
| - var mwb = serverMaxWindowBits == null ? 15 : serverMaxWindowBits; |
| + var mwb = serverMaxWindowBits == null ? _WebSocketImpl.DEFAULT_WINDOW_BITS : serverMaxWindowBits; |
|
kustermann
2015/07/20 09:34:12
long line
|
| header += "; server_max_window_bits=${mwb}"; |
| } |
| @@ -140,7 +147,6 @@ class CompressionOptions { |
| */ |
| abstract class WebSocketTransformer |
| implements StreamTransformer<HttpRequest, WebSocket> { |
| - |
| /** |
| * Create a new [WebSocketTransformer]. |
| * |
| @@ -150,9 +156,10 @@ abstract class WebSocketTransformer |
| * completing with a [String]. The [String] must exist in the list of |
| * protocols. |
| */ |
| - factory WebSocketTransformer({protocolSelector(List<String> protocols), |
| - CompressionOptions compression: CompressionOptions.DEFAULT}) |
| - => new _WebSocketTransformerImpl(protocolSelector, compression); |
| + factory WebSocketTransformer( |
| + {protocolSelector(List<String> protocols), |
| + CompressionOptions compression: CompressionOptions.DEFAULT}) => |
| + new _WebSocketTransformerImpl(protocolSelector, compression); |
| /** |
| * Upgrades a [HttpRequest] to a [WebSocket] connection. If the |
| @@ -168,9 +175,10 @@ abstract class WebSocketTransformer |
| * protocols. |
| */ |
| static Future<WebSocket> upgrade(HttpRequest request, |
| - {protocolSelector(List<String> protocols), |
| - CompressionOptions compression: CompressionOptions.DEFAULT}) { |
| - return _WebSocketTransformerImpl._upgrade(request, protocolSelector, compression); |
| + {protocolSelector(List<String> protocols), |
| + CompressionOptions compression: CompressionOptions.DEFAULT}) { |
| + return _WebSocketTransformerImpl._upgrade( |
| + request, protocolSelector, compression); |
| } |
| /** |
| @@ -181,7 +189,6 @@ abstract class WebSocketTransformer |
| } |
| } |
| - |
| /** |
| * A two-way HTTP communication object for client or server applications. |
| * |
| @@ -241,8 +248,7 @@ abstract class WebSocket implements Stream, StreamSink { |
| * authentication when setting up the connection. |
| */ |
| static Future<WebSocket> connect(String url, |
| - {Iterable<String> protocols, |
| - Map<String, dynamic> headers}) => |
| + {Iterable<String> protocols, Map<String, dynamic> headers}) => |
| _WebSocketImpl.connect(url, protocols, headers); |
| @Deprecated('This constructor will be removed in Dart 2.0. Use `implements`' |
| @@ -264,13 +270,16 @@ abstract class WebSocket implements Stream, StreamSink { |
| * act as the client and mask the messages it sends. If it's `true`, it will |
| * act as the server and will not mask its messages. |
| */ |
| - factory WebSocket.fromUpgradedSocket(Socket socket, {String protocol, |
| - bool serverSide, CompressionOptions compression: CompressionOptions.DEFAULT}) { |
| + factory WebSocket.fromUpgradedSocket(Socket socket, |
| + {String protocol, |
| + bool serverSide, |
| + CompressionOptions compression: CompressionOptions.DEFAULT}) { |
| if (serverSide == null) { |
| throw new ArgumentError("The serverSide argument must be passed " |
| "explicitly to WebSocket.fromUpgradedSocket."); |
| } |
| - return new _WebSocketImpl._fromSocket(socket, protocol, compression, serverSide); |
| + return new _WebSocketImpl._fromSocket( |
| + socket, protocol, compression, serverSide); |
| } |
| /** |
| @@ -327,9 +336,10 @@ abstract class WebSocket implements Stream, StreamSink { |
| Future addStream(Stream stream); |
| } |
| - |
| class WebSocketException implements IOException { |
| final String message; |
| + |
| const WebSocketException([this.message = ""]); |
| + |
| String toString() => "WebSocketException: $message"; |
| } |