diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 2b48dcdc..6420aabf 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -641,7 +641,8 @@ Extended Payload Length: {7} Stream stream, WebSocketFrame frame, Action completed, - Action error) + Action error + ) { var len = frame.FullPayloadLength; if (len == 0) { @@ -651,18 +652,22 @@ Extended Payload Length: {7} return; } - 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; - Action compl = bytes => { - if (bytes.LongLength != llen) - throw new WebSocketException ( - "The payload data of a frame cannot be read from the stream."); + Action compl = + bytes => { + 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); - completed (frame); - }; + frame._payloadData = new PayloadData (bytes, llen); + completed (frame); + }; if (frame._payloadLength < 127) { stream.ReadBytesAsync ((int) len, compl, error);