From e44a6c799f516ff32a34dfac4d05651b742b1fda Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 17 Aug 2019 22:01:51 +0900 Subject: [PATCH] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 0a2df996..2b48dcdc 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -608,7 +608,9 @@ Extended Payload Length: {7} ); } - private static WebSocketFrame readPayloadData (Stream stream, WebSocketFrame frame) + private static WebSocketFrame readPayloadData ( + Stream stream, WebSocketFrame frame + ) { var len = frame.FullPayloadLength; if (len == 0) { @@ -616,17 +618,20 @@ Extended Payload Length: {7} return frame; } - if (len > PayloadData.MaxLength) - throw new WebSocketException (CloseStatusCode.TooBig, "A frame has a long payload length."); + if (len > PayloadData.MaxLength) { + var msg = "A frame has too long payload data length."; + throw new WebSocketException (CloseStatusCode.TooBig, msg); + } var llen = (long) len; var bytes = frame._payloadLength < 127 ? stream.ReadBytes ((int) len) : stream.ReadBytes (llen, 1024); - if (bytes.LongLength != llen) - throw new WebSocketException ( - "The payload data of a frame cannot be read from the stream."); + if (bytes.LongLength != llen) { + var msg = "The payload data of a frame could not be read."; + throw new WebSocketException (msg); + } frame._payloadData = new PayloadData (bytes, llen); return frame;