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

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: Addressed review comments 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
« no previous file with comments | « sdk/lib/io/websocket.dart ('k') | tests/standalone/io/web_socket_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..6e308094aabceb22ef8580c0e658a8cecdc649c4 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.
@@ -796,6 +793,13 @@ class _WebSocketImpl extends Stream with _ServiceObject implements WebSocket {
fragment: uri.fragment);
return _httpClient.openUrl("GET", uri)
.then((request) {
+ 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");
+ }
if (headers != null) {
headers.forEach((field, value) => request.headers.add(field, value));
}
« no previous file with comments | « sdk/lib/io/websocket.dart ('k') | tests/standalone/io/web_socket_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698