From 296ede4c33e4412b3a476f4985db7665982e79ae Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 11 Aug 2016 16:59:55 +0900 Subject: [PATCH] [Modify] Move it out --- websocket-sharp/WebSocket.cs | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 19f68b46..4aebd11f 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2818,6 +2818,22 @@ namespace WebSocketSharp return; } + if (!username.IsNullOrEmpty ()) { + if (username.Contains (':') || !username.IsText ()) { + _logger.Error ("'username' contains an invalid character."); + error ("An error has occurred in setting the credentials.", null); + + return; + } + + if (!password.IsNullOrEmpty () && !password.IsText ()) { + _logger.Error ("'password' contains an invalid character."); + error ("An error has occurred in setting the credentials.", null); + + return; + } + } + lock (_forState) { if (!checkIfAvailable (true, false, false, true, out msg)) { _logger.Error (msg); @@ -2834,20 +2850,6 @@ namespace WebSocketSharp return; } - if (username.Contains (':') || !username.IsText ()) { - _logger.Error ("'username' contains an invalid character."); - error ("An error has occurred in setting the credentials.", null); - - return; - } - - if (!password.IsNullOrEmpty () && !password.IsText ()) { - _logger.Error ("'password' contains an invalid character."); - error ("An error has occurred in setting the credentials.", null); - - return; - } - _credentials = new NetworkCredential (username, password, _uri.PathAndQuery); _preAuth = preAuth; }