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

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

Issue 14595006: Extend HTTP digest support with server changing nonce (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments Created 7 years, 8 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 31f2a489eb8368291fe54e74e50cfb261bfeac33..33d8d2405d6d929aaf6a8eab8498959db2f3c711 100644
--- a/sdk/lib/io/http_impl.dart
+++ b/sdk/lib/io/http_impl.dart
@@ -311,18 +311,24 @@ class _HttpClientResponse
if (cr.scheme == _AuthenticationScheme.DIGEST &&
(header.parameters["algorithm"] == null ||
header.parameters["algorithm"].toLowerCase() == "md5")) {
- // If the nonce is not set then this is the first authenticate
- // response for these credentials.
- // TODO(sgjesse): Check for changed nonce.
- if (cr.nonce == null) {
- // Set up authentication state.
+ if (cr.nonce == null || cr.nonce == header.parameters["nonce"]) {
+ // If the nonce is not set then this is the first authenticate
+ // response for these credentials. Set up authentication state.
+ if (cr.nonce == null) {
+ cr.nonce = header.parameters["nonce"];
+ cr.algorithm = "MD5";
+ cr.qop = header.parameters["qop"];
+ cr.nonceCount = 0;
+ }
+ // Credentials where found, prepare for retrying the request.
+ return retryWithCredentials(cr);
+ } else if (header.parameters["stale"] != null &&
+ header.parameters["stale"].toLowerCase() == "true") {
+ // If stale is true retry with new nonce.
cr.nonce = header.parameters["nonce"];
- cr.algorithm = "MD5";
- cr.qop = header.parameters["qop"];
- cr.nonceCount = 0;
+ // Credentials where found, prepare for retrying the request.
+ return retryWithCredentials(cr);
}
- // Credentials where found, prepare for retrying the request.
- return retryWithCredentials(cr);
}
}
@@ -1114,6 +1120,7 @@ class _HttpClientConnection {
_HttpClientRequest send(Uri uri, int port, String method, _Proxy proxy) {
// Start with pausing the parser.
_subscription.pause();
+ _Credentials cr; // Credentials used to authorize this request.
var outgoing = new _HttpOutgoing(_socket);
// Create new request object, wrapping the outgoing connection.
var request = new _HttpClientRequest(outgoing,
@@ -1145,7 +1152,7 @@ class _HttpClientConnection {
request.headers.set(HttpHeaders.AUTHORIZATION, "Basic $auth");
} else {
// Look for credentials.
- _Credentials cr = _httpClient._findCredentials(uri);
+ cr = _httpClient._findCredentials(uri);
if (cr != null) {
cr.authorize(request);
}
@@ -1172,6 +1179,18 @@ class _HttpClientConnection {
destroy();
}
});
+ // For digest authentication check if the server
+ // requests the client to start using a new nonce.
+ if (cr != null && cr.scheme == _AuthenticationScheme.DIGEST) {
+ var authInfo = incoming.headers["authentication-info"];
+ if (authInfo != null && authInfo.length == 1) {
+ var header =
+ new _HeaderValue.fromString(
+ authInfo[0], parameterSeparator: ',');
+ var nextnonce = header.parameters["nextnonce"];
+ if (nextnonce != null) cr.nonce = nextnonce;
+ }
+ }
request._onIncoming(incoming);
})
// If we see a state error, we failed to get the 'first'
« 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