Index: sdk/lib/io/websocket.dart |
diff --git a/sdk/lib/io/websocket.dart b/sdk/lib/io/websocket.dart |
index 3a65685259c89df5d92999645ca84c3c1fa846d4..2d2fe8326db0371a5c25dfe971740ff1a116d4c0 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 |
@@ -86,18 +90,21 @@ class CompressionOptions { |
header += "; client_max_window_bits"; |
} else { |
if (requested.contains("client_max_window_bits")) { |
- var myMaxWindowBits = clientMaxWindowBits == null ? 15 : clientMaxWindowBits; |
+ var myMaxWindowBits = |
+ clientMaxWindowBits == null ? 15 : clientMaxWindowBits; |
Søren Gjesse
2015/07/03 13:14:54
Please use a constant for 15.
|
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"))) { |
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"))) { |
header += "; server_no_context_takeover"; |
} |
@@ -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"; |
} |