anchor.diff:      // already been used. If it has already been used it must now be
       // invalid and is removed.
       if (cr != null) {
  -      _httpClient._removeCredentials(cr);
  +      removeCredentials(cr);
         cr = null;
       }
  -    if (_httpClient._authenticate != null) {
  -      Future authComplete = _httpClient._authenticate(_httpRequest.uri,
  -                                                      scheme.toString(),
  -                                                      realm);
  -      return authComplete.then((credsAvailable) {
  -        if (credsAvailable) {
  -          cr = _httpClient._findCredentials(_httpRequest.uri, scheme);
  -          return retryWithCredentials(cr);
  -        } else {
  -          // No credentials available, complete with original response.
  -          return this;
  -        }
  -      });
  -    }
  -
  -    // No credentials were found and the callback was not set.
  -    return new Future.value(this);
  -  }
  -
  -  Future<HttpClientResponse> _authenticateProxy() {
  -    Future<HttpClientResponse> retryWithProxyCredentials(_ProxyCredentials cr) {
  -      return fold(null, (x, y) {}).then((_) {
  -          return _httpClient._openUrlFromRequest(_httpRequest.method,
  -                                                 _httpRequest.uri,
  -                                                 _httpRequest)
  -              .then((request) => request.close());
  -        });
  -    }
  -
  -    List<String> challenge = headers[HttpHeaders.PROXY_AUTHENTICATE];
  -    assert(challenge != null || challenge.length == 1);
  -    _HeaderValue header =
  -        _HeaderValue.parse(challenge[0], parameterSeparator: ",");
  -    _AuthenticationScheme scheme =
  -        new _AuthenticationScheme.fromString(header.value);
  -    String realm = header.parameters["realm"];
  -
  -    // See if any credentials are available.
  -    var proxy = _httpRequest._proxy;
  -
  -    var cr =  _httpClient._findProxyCredentials(proxy);
  -    if (cr != null) {
  -      if (cr.scheme == _AuthenticationScheme.BASIC) {
  -        return retryWithProxyCredentials(cr);
  -      }
  -
  -      // Digest authentication only supports the MD5 algorithm.
  -      if (cr.scheme == _AuthenticationScheme.DIGEST &&
  -          (header.parameters["algorithm"] == null ||
  -           header.parameters["algorithm"].toLowerCase() == "md5")) {
  -        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 retryWithProxyCredentials(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"];
  -          // Credentials where found, prepare for retrying the request.
  -          return retryWithProxyCredentials(cr);
  -        }
  -      }
  -    }
  -
  -    // Ask for more credentials if none found.
  -    if (_httpClient._authenticateProxy != null) {
  -      Future authComplete = _httpClient._authenticateProxy(proxy.host,
  -                                                           proxy.port,
  -                                                           "basic",
  -                                                           realm);
  -      return authComplete.then((credsAvailable) {
  -        if (credsAvailable) {
  -          var cr =  _httpClient._findProxyCredentials(proxy);
  -          return retryWithProxyCredentials(cr);
  -        } else {
  -          // No credentials available, complete with original response.
  -          return this;
  -        }
  -      });
  -    }
  -
  -    // No credentials were found and the callback was not set.
  -    return new Future.value(this);
  +    return requestAuthentication(scheme, realm).then((credsAvailable) {
  +      if (credsAvailable) {
  +        cr = _httpClient._findCredentials(_httpRequest.uri, scheme);
  +        return retry();
  +      } else {
  +        // No credentials available, complete with original response.
  +        return this;
  +      }
  +    });
     }
   }
   
  
positive.code:   : super(creds, realm);
  
    bool applies(_Proxy proxy, _AuthenticationScheme scheme) {
      return proxy.host == host && proxy.port == port;
    }
  
  
negative.code:             cr.nonceCount = 0;
            }
            // Credentials where found, prepare for retrying the request.
            return retry();
          } else if (header.parameters["stale"] != null &&
                     header.parameters["stale"].toLowerCase() == "true") {
            // If stale is true retry with new nonce.
            cr.nonce = header.parameters["nonce"];
            // Credentials where found, prepare for retrying the request.
            return retry();
          }
        }
      }
  