From f090fa9d5d79845204677213d5b9fab6d9dec485 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 22 Dec 2014 14:57:52 +0900 Subject: [PATCH] Added some logs for the authentication --- websocket-sharp/WebSocket.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index e8a79b24..c2f5930f 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1254,7 +1254,19 @@ namespace WebSocketSharp var req = createHandshakeRequest (); var res = sendHttpRequest (req, 90000); if (res.IsUnauthorized) { - _authChallenge = res.AuthenticationChallenge; + 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) {