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

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

Issue 839063005: Allow additional headers for WebSocket connect (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Changed List to Iterable Created 5 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
« no previous file with comments | « no previous file | sdk/lib/io/websocket_impl.dart » ('j') | sdk/lib/io/websocket_impl.dart » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 /** 7 /**
8 * Web socket status codes used when closing a web socket connection. 8 * Web socket status codes used when closing a web socket connection.
9 */ 9 */
10 abstract class WebSocketStatus { 10 abstract class WebSocketStatus {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 * select what protocol to use, if any were provided by the client. 61 * select what protocol to use, if any were provided by the client.
62 * [protocolSelector] is should return either a [String] or a [Future] 62 * [protocolSelector] is should return either a [String] or a [Future]
63 * completing with a [String]. The [String] must exist in the list of 63 * completing with a [String]. The [String] must exist in the list of
64 * protocols. 64 * protocols.
65 */ 65 */
66 factory WebSocketTransformer({protocolSelector(List<String> protocols)}) 66 factory WebSocketTransformer({protocolSelector(List<String> protocols)})
67 => new _WebSocketTransformerImpl(protocolSelector); 67 => new _WebSocketTransformerImpl(protocolSelector);
68 68
69 /** 69 /**
70 * Upgrades a [HttpRequest] to a [WebSocket] connection. If the 70 * Upgrades a [HttpRequest] to a [WebSocket] connection. If the
71 * request is not a valid web socket upgrade request a HTTP response 71 * request is not a valid web socket upgrade request a HTTP response
Lasse Reichstein Nielsen 2015/01/14 10:49:21 a HTTP -> an HTTP
72 * with status code 500 will be returned. Otherwise the returned 72 * with status code 500 will be returned. Otherwise the returned
73 * future will complete with the [WebSocket] when the upgrade pocess 73 * future will complete with the [WebSocket] when the upgrade pocess
74 * is complete. 74 * is complete.
75 * 75 *
76 * If [protocolSelector] is provided, [protocolSelector] will be called to 76 * If [protocolSelector] is provided, [protocolSelector] will be called to
77 * select what protocol to use, if any were provided by the client. 77 * select what protocol to use, if any were provided by the client.
78 * [protocolSelector] is should return either a [String] or a [Future] 78 * [protocolSelector] is should return either a [String] or a [Future]
79 * completing with a [String]. The [String] must exist in the list of 79 * completing with a [String]. The [String] must exist in the list of
80 * protocols. 80 * protocols.
81 */ 81 */
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 * There are never two outstanding pings at any given time, and the next ping 118 * There are never two outstanding pings at any given time, and the next ping
119 * timer starts when the pong is received. 119 * timer starts when the pong is received.
120 * 120 *
121 * Set the [pingInterval] to `null` to disable sending ping messages. 121 * Set the [pingInterval] to `null` to disable sending ping messages.
122 * 122 *
123 * The default value is `null`. 123 * The default value is `null`.
124 */ 124 */
125 Duration pingInterval; 125 Duration pingInterval;
126 126
127 /** 127 /**
128 * Create a new web socket connection. The URL supplied in [url] 128 * Create a new web socket connection. The URL supplied in [url]
Lasse Reichstein Nielsen 2015/01/14 10:49:21 I think "web socket" is usually written "WebSocket
Søren Gjesse 2015/01/14 13:54:26 Done.
129 * must use the scheme [:ws:] or [:wss:]. The [protocols] argument is 129 * must use the scheme `ws` or `wss`.
130 * specifying the subprotocols the client is willing to speak. 130 *
131 * The [protocols] argument is specifying the subprotocols the
132 * client is willing to speak.
133 *
134 * The [headers] argument is specifying additional HTTP headers for
135 * the initial upgrade request. This would typically be the `Origin`
136 * header and potentially cookies. The key of the map are the header
Lasse Reichstein Nielsen 2015/01/14 10:49:21 The key -> The keys.
Søren Gjesse 2015/01/14 13:54:26 Done.
137 * fields and the values are either String or List<String>.
Lasse Reichstein Nielsen 2015/01/14 10:49:21 What is an "upgrade request"? Either say something
Søren Gjesse 2015/01/14 13:54:26 Changed the initial upgrade request to setting
138 *
139 * Even if [headers] is provided, there are a number of headers
Lasse Reichstein Nielsen 2015/01/14 10:49:21 Drop the "even" part. Just go directly to the fact
Søren Gjesse 2015/01/14 13:54:26 Done.
140 * which are controlled by the web socket connection process. These
141 * headers are: `connection`, `sec-websocket-version`,
142 * `sec-websocket-key`, `upgrade` and `sec-websocket-protocol`. If
Lasse Reichstein Nielsen 2015/01/14 10:49:21 Put the headers in alphabetical order. It looks ra
Søren Gjesse 2015/01/14 13:54:26 Done.
143 * any of these are passed in the `headers` they will be ignored.
Lasse Reichstein Nielsen 2015/01/14 10:49:21 add "map" after `headers`. Just "the headers" does
Søren Gjesse 2015/01/14 13:54:26 Done.
131 */ 144 */
132 static Future<WebSocket> connect(String url, 145 static Future<WebSocket> connect(String url,
133 {List<String> protocols: const []}) => 146 {Iterable<String> protocols: const [],
Lasse Reichstein Nielsen 2015/01/14 10:49:21 I'd use "null" as default, and then do the dispatc
Søren Gjesse 2015/01/14 13:54:26 Done.
134 _WebSocketImpl.connect(url, protocols); 147 Map<String, dynamic> headers}) =>
148 _WebSocketImpl.connect(url, protocols, headers);
135 149
136 @Deprecated('This constructor will be removed in Dart 2.0. Use `implements`' 150 @Deprecated('This constructor will be removed in Dart 2.0. Use `implements`'
137 ' instead of `extends` if implementing this abstract class.') 151 ' instead of `extends` if implementing this abstract class.')
138 WebSocket(); 152 WebSocket();
139 153
140 /** 154 /**
141 * Creates a WebSocket from an already-upgraded socket. 155 * Creates a WebSocket from an already-upgraded socket.
142 * 156 *
143 * The initial WebSocket handshake must have occurred prior to this call. A 157 * The initial WebSocket handshake must have occurred prior to this call. A
144 * WebSocket client can automatically perform the handshake using 158 * WebSocket client can automatically perform the handshake using
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 */ 228 */
215 Future addStream(Stream stream); 229 Future addStream(Stream stream);
216 } 230 }
217 231
218 232
219 class WebSocketException implements IOException { 233 class WebSocketException implements IOException {
220 final String message; 234 final String message;
221 const WebSocketException([this.message = ""]); 235 const WebSocketException([this.message = ""]);
222 String toString() => "WebSocketException: $message"; 236 String toString() => "WebSocketException: $message";
223 } 237 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/io/websocket_impl.dart » ('j') | sdk/lib/io/websocket_impl.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698