diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 817ef568..bebdb7b7 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -801,16 +801,16 @@ namespace WebSocketSharp.Net if (cred == null) return null; - if (scheme == AuthenticationSchemes.Basic - && ((HttpBasicIdentity) id).Password != cred.Password - ) { - return null; + if (scheme == AuthenticationSchemes.Basic) { + var basicId = (HttpBasicIdentity) id; + if (basicId.Password != cred.Password) + return null; } - if (scheme == AuthenticationSchemes.Digest - && !((HttpDigestIdentity) id).IsValid (cred.Password, realm, method, null) - ) { - return null; + if (scheme == AuthenticationSchemes.Digest) { + var digestId = (HttpDigestIdentity) id; + if (!digestId.IsValid (cred.Password, realm, method, null)) + return null; } return new GenericPrincipal (id, cred.Roles);