Fix a few for WebSocket.cs
This commit is contained in:
parent
87068bc4f3
commit
12b4af3628
@ -511,26 +511,22 @@ namespace WebSocketSharp
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void acceptException (Exception exception, string reason)
|
private void acceptException (Exception exception, string message)
|
||||||
{
|
{
|
||||||
var code = CloseStatusCode.Abnormal;
|
var code = CloseStatusCode.Abnormal;
|
||||||
var msg = reason;
|
var reason = message;
|
||||||
if (exception is WebSocketException) {
|
if (exception is WebSocketException) {
|
||||||
var wsex = (WebSocketException) exception;
|
var wsex = (WebSocketException) exception;
|
||||||
code = wsex.Code;
|
code = wsex.Code;
|
||||||
reason = wsex.Message;
|
reason = wsex.Message;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (code == CloseStatusCode.Abnormal || code == CloseStatusCode.TlsHandshakeFailure) {
|
if (code == CloseStatusCode.Abnormal || code == CloseStatusCode.TlsHandshakeFailure)
|
||||||
_logger.Fatal (exception.ToString ());
|
_logger.Fatal (exception.ToString ());
|
||||||
reason = msg;
|
else
|
||||||
}
|
|
||||||
else {
|
|
||||||
_logger.Error (reason);
|
_logger.Error (reason);
|
||||||
msg = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
error (msg ?? code.GetMessage ());
|
error (message ?? code.GetMessage ());
|
||||||
if (_readyState == WebSocketState.Connecting && !_client)
|
if (_readyState == WebSocketState.Connecting && !_client)
|
||||||
Close (HttpStatusCode.BadRequest);
|
Close (HttpStatusCode.BadRequest);
|
||||||
else
|
else
|
||||||
@ -2031,8 +2027,8 @@ namespace WebSocketSharp
|
|||||||
len));
|
len));
|
||||||
|
|
||||||
var sent = len <= FragmentLength
|
var sent = len <= FragmentLength
|
||||||
? send (Opcode.Binary, data)
|
? send (Opcode.Binary, data)
|
||||||
: send (Opcode.Binary, new MemoryStream (data));
|
: send (Opcode.Binary, new MemoryStream (data));
|
||||||
|
|
||||||
if (completed != null)
|
if (completed != null)
|
||||||
completed (sent);
|
completed (sent);
|
||||||
@ -2098,10 +2094,10 @@ namespace WebSocketSharp
|
|||||||
}
|
}
|
||||||
|
|
||||||
msg = username.Contains (':') || !username.IsText ()
|
msg = username.Contains (':') || !username.IsText ()
|
||||||
? "'username' contains an invalid character."
|
? "'username' contains an invalid character."
|
||||||
: !password.IsNullOrEmpty () && !password.IsText ()
|
: !password.IsNullOrEmpty () && !password.IsText ()
|
||||||
? "'password' contains an invalid character."
|
? "'password' contains an invalid character."
|
||||||
: null;
|
: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg != null) {
|
if (msg != null) {
|
||||||
|
Loading…
Reference in New Issue
Block a user