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

Unified Diff: sdk/lib/io/websocket_impl.dart

Issue 897323002: Add support for user info on ws: and wss: URLs (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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 ae4c91ce6208f76e2d346c701f2e5fe0831a2786..cdaa3a0e448f5be006824667bb9078ce5a2b3cc4 100644
--- a/sdk/lib/io/websocket_impl.dart
+++ b/sdk/lib/io/websocket_impl.dart
@@ -775,9 +775,6 @@ class _WebSocketImpl extends Stream with _ServiceObject implements WebSocket {
if (uri.scheme != "ws" && uri.scheme != "wss") {
throw new WebSocketException("Unsupported URL scheme '${uri.scheme}'");
}
- if (uri.userInfo != "") {
- throw new WebSocketException("Unsupported user info '${uri.userInfo}'");
- }
Random random = new Random();
// Generate 16 random bytes.
@@ -809,6 +806,13 @@ class _WebSocketImpl extends Stream with _ServiceObject implements WebSocket {
if (protocols != null) {
request.headers.add("Sec-WebSocket-Protocol", protocols.toList());
}
+ if (uri.userInfo != null && !uri.userInfo.isEmpty) {
+ // If the URL contains user information use that for basic
+ // authorization.
+ String auth =
+ _CryptoUtils.bytesToBase64(UTF8.encode(uri.userInfo));
+ request.headers.set(HttpHeaders.AUTHORIZATION, "Basic $auth");
+ }
kustermann 2015/02/06 13:13:46 Maybe move this before the `if (headers != null) {
Søren Gjesse 2015/02/09 10:38:59 Good point, done.
return request.close();
})
.then((response) {

Powered by Google App Engine
This is Rietveld 408576698