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

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: 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..6683bdeeb048d19a25272d77c7995bdbb8e60c65 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, List<String> protocols, Function onRequest) {
Uri uri = Uri.parse(url);
if (uri.scheme != "ws" && uri.scheme != "wss") {
throw new WebSocketException("Unsupported URL scheme '${uri.scheme}'");
@@ -800,12 +801,18 @@ class _WebSocketImpl extends Stream with _ServiceObject implements WebSocket {
..add(HttpHeaders.CONNECTION, "Upgrade")
..set(HttpHeaders.UPGRADE, "websocket")
..set("Sec-WebSocket-Key", nonce)
- ..set("Cache-Control", "no-cache")
kustermann 2015/01/09 14:45:12 Why was this removed?
Søren Gjesse 2015/01/12 15:36:34 I thought it was not needed as a proxy should neve
..set("Sec-WebSocket-Version", "13");
if (protocols.isNotEmpty) {
request.headers.add("Sec-WebSocket-Protocol", protocols);
}
- return request.close();
+ if (onRequest != null) {
+ var result = onRequest(request);
+ return result is Future
Lasse Reichstein Nielsen 2015/01/12 15:11:56 Parentheses around (result is Future) expression (
Søren Gjesse 2015/01/12 15:36:34 Dropped this code.
+ ? result.then((_) => request.close())
+ : request.close();
+ } else {
+ return request.close();
+ }
Lasse Reichstein Nielsen 2015/01/12 15:11:56 Rewrite as: if (onRequest != null) { var result
Søren Gjesse 2015/01/12 15:36:34 Dropped this code.
})
.then((response) {
void error(String message) {

Powered by Google App Engine
This is Rietveld 408576698