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

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

Issue 14595008: Fix digest authentication to use the correct URI (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 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 | « no previous file | tests/standalone/io/http_auth_digest_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/http_impl.dart
diff --git a/sdk/lib/io/http_impl.dart b/sdk/lib/io/http_impl.dart
index 8ea7174e6a3040eb1135f88c507448b48d051a64..661858c248d426af5b0d89c4c6a2dc27ad7d727d 100644
--- a/sdk/lib/io/http_impl.dart
+++ b/sdk/lib/io/http_impl.dart
@@ -914,49 +914,54 @@ class _HttpClientRequest extends _HttpOutboundMessage<HttpClientResponse>
_responseCompleter.completeError(error);
}
- void _writeHeader() {
- var buffer = new _BufferList();
-
- writeSP() => buffer.add(const [_CharCode.SP]);
-
- writeCRLF() => buffer.add(const [_CharCode.CR, _CharCode.LF]);
-
- void writePath() {
- String path = uri.path;
- if (path.length == 0) path = "/";
+ // Generate the request URI based on the method and proxy.
+ String _requestUri() {
+ // Generate the request URI starting from the path component.
+ String uriStartingFromPath() {
+ String result = uri.path;
+ if (result.length == 0) result = "/";
if (uri.query != "") {
if (uri.fragment != "") {
- path = "${path}?${uri.query}#${uri.fragment}";
+ result = "${result}?${uri.query}#${uri.fragment}";
} else {
- path = "${path}?${uri.query}";
+ result = "${result}?${uri.query}";
}
}
- buffer.add(path.codeUnits);
+ return result;
}
- // Write the request method.
- buffer.add(method.codeUnits);
- writeSP();
- // Write the request URI.
if (_proxy.isDirect) {
- writePath();
+ return uriStartingFromPath();
} else {
if (method == "CONNECT") {
// For the connect method the request URI is the host:port of
// the requested destination of the tunnel (see RFC 2817
// section 5.2)
- buffer.add(uri.domain.codeUnits);
- buffer.add(const [_CharCode.COLON]);
- buffer.add(uri.port.toString().codeUnits);
+ return "${uri.domain}:${uri.port}";
} else {
if (_httpClientConnection._proxyTunnel) {
- writePath();
+ return uriStartingFromPath();
} else {
- buffer.add(uri.toString().codeUnits);
+ return uri.toString();
}
}
}
+ }
+
+ void _writeHeader() {
+ var buffer = new _BufferList();
+
+ writeSP() => buffer.add(const [_CharCode.SP]);
+
+ writeCRLF() => buffer.add(const [_CharCode.CR, _CharCode.LF]);
+
+ // Write the request method.
+ buffer.add(method.codeUnits);
+ writeSP();
+ // Write the request URI.
+ buffer.add(_requestUri().codeUnits);
writeSP();
+ // Write HTTP/1.1.
buffer.add(_Const.HTTP11);
writeCRLF();
@@ -2134,10 +2139,11 @@ class _HttpClientDigestCredentials
_AuthenticationScheme get scheme => _AuthenticationScheme.DIGEST;
String authorization(_Credentials credentials, HttpClientRequest request) {
+ String requestUri = request._requestUri();
MD5 hasher = new MD5();
hasher.add(request.method.codeUnits);
hasher.add([_CharCode.COLON]);
- hasher.add(request.uri.path.codeUnits);
+ hasher.add(requestUri.codeUnits);
var ha2 = CryptoUtils.bytesToHex(hasher.close());
String qop;
@@ -2174,7 +2180,7 @@ class _HttpClientDigestCredentials
buffer.write('username="$username"');
buffer.write(', realm="${credentials.realm}"');
buffer.write(', nonce="${credentials.nonce}"');
- buffer.write(', uri="${request.uri.path}"');
+ buffer.write(', uri="$requestUri"');
buffer.write(', algorithm="${credentials.algorithm}"');
if (qop == "auth") {
buffer.write(', qop="$qop"');
« no previous file with comments | « no previous file | tests/standalone/io/http_auth_digest_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698