// As client private HttpResponse sendHandshakeRequest() { var req = createHandshakeRequest (); var res = sendHttpRequest (req, 90000); if (res.IsUnauthorized) { var chal = res.Headers["WWW-Authenticate"]; _logger.Warn (String.Format ("Received an authentication requirement for '{0}'.", chal)); if (chal.IsNullOrEmpty ()) { _logger.Error ("No authentication challenge is specified."); return res; } _authChallenge = AuthenticationChallenge.Parse (chal); if (_authChallenge == null) { _logger.Error ("An invalid authentication challenge is specified."); return res; } if (_credentials != null && (!_preAuth || _authChallenge.Scheme == AuthenticationSchemes.Digest)) { if (res.HasConnectionClose) { releaseClientResources (); setClientStream (); } var authRes = new AuthenticationResponse (_authChallenge, _credentials, _nonceCount); _nonceCount = authRes.NonceCount; req.Headers["Authorization"] = authRes.ToString (); res = sendHttpRequest (req, 15000); } } if (res.IsRedirect) { var url = res.Headers["Location"]; _logger.Warn (String.Format ("Received a redirection to '{0}'.", url)); if (_enableRedirection) { if (url.IsNullOrEmpty ()) { _logger.Error ("No url to redirect is located."); return res; } Uri uri; string msg; if (!url.TryCreateWebSocketUri (out uri, out msg)) { _logger.Error ("An invalid url to redirect is located: " + msg); return res; } releaseClientResources (); _uri = uri; _secure = uri.Scheme == "wss"; setClientStream (); return sendHandshakeRequest (); } } return res; }
internal AuthenticationResponse( AuthenticationChallenge challenge, NetworkCredential credentials, uint nonceCount) : this(challenge.Scheme, challenge.Parameters, credentials, nonceCount) { }