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

Unified Diff: sdk/lib/io/websocket_impl.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 side-by-side diff with in-line comments
Download patch
Index: sdk/lib/io/websocket_impl.dart
diff --git a/sdk/lib/io/websocket_impl.dart b/sdk/lib/io/websocket_impl.dart
index 872cd321ad7b223deadefd840311925fe9f123b8..19ebfbf532e2843392053a16f0b33869a728446c 100644
--- a/sdk/lib/io/websocket_impl.dart
+++ b/sdk/lib/io/websocket_impl.dart
@@ -769,7 +769,8 @@ class _WebSocketImpl extends Stream with _ServiceObject implements WebSocket {
static final HttpClient _httpClient = new HttpClient();
- static Future<WebSocket> connect(String url, List<String> protocols) {
+ static Future<WebSocket> connect(
+ String url, Iterable<String> protocols, Map<String, dynamic> headers) {
Uri uri = Uri.parse(url);
if (uri.scheme != "ws" && uri.scheme != "wss") {
throw new WebSocketException("Unsupported URL scheme '${uri.scheme}'");
@@ -795,6 +796,9 @@ class _WebSocketImpl extends Stream with _ServiceObject implements WebSocket {
fragment: uri.fragment);
return _httpClient.openUrl("GET", uri)
.then((request) {
+ if (headers != null) {
+ headers.forEach((field, value) => request.headers.add(field, value));
+ }
// Setup the initial handshake.
request.headers
..add(HttpHeaders.CONNECTION, "Upgrade")
kustermann 2015/01/14 11:42:17 Why is this an .add() and not a .set(). If the u
Søren Gjesse 2015/01/14 13:54:26 Good catch.

Powered by Google App Engine
This is Rietveld 408576698