From 40429228101446a485e555fb1f6d955b0be89eaf Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 24 Dec 2014 15:47:44 +0900 Subject: [PATCH] Added checking more for the proxy authentication --- websocket-sharp/WebSocket.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index c2f5930f..6a40ca4b 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1333,9 +1333,19 @@ namespace WebSocketSharp var req = HttpRequest.CreateConnectRequest (_uri); var res = sendHttpRequest (req, 90000); if (res.IsProxyAuthenticationRequired) { - var authChal = res.ProxyAuthenticationChallenge; - if (authChal != null && _proxyCredentials != null) { - if (res.Headers.Contains ("Connection", "close")) { + var chal = res.Headers["Proxy-Authenticate"]; + _logger.Warn ( + String.Format ("Received a proxy authentication requirement for '{0}'.", chal)); + + if (chal.IsNullOrEmpty ()) + throw new WebSocketException ("No proxy authentication challenge is specified."); + + var authChal = AuthenticationChallenge.Parse (chal); + if (authChal == null) + throw new WebSocketException ("An invalid proxy authentication challenge is specified."); + + if (_proxyCredentials != null) { + if (res.HasConnectionClose) { releaseClientResources (); _tcpClient = new TcpClient (_proxyUri.DnsSafeHost, _proxyUri.Port); _stream = _tcpClient.GetStream ();