Skip to content

Commit a0104e9

Browse files
committed
[Modify] Polish it
1 parent a06e8ea commit a0104e9

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

websocket-sharp/WebSocketFrame.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,32 +699,39 @@ Action<Exception> error
699699
)
700700
{
701701
var exactLen = frame.ExactPayloadLength;
702+
702703
if (exactLen > PayloadData.MaxLength) {
703704
var msg = "A frame has too long payload length.";
705+
704706
throw new WebSocketException (CloseStatusCode.TooBig, msg);
705707
}
706708

707709
if (exactLen == 0) {
708710
frame._payloadData = PayloadData.Empty;
711+
709712
completed (frame);
710713

711714
return;
712715
}
713716

714717
var len = (long) exactLen;
718+
715719
Action<byte[]> comp =
716720
bytes => {
717721
if (bytes.LongLength != len) {
718722
var msg = "The payload data of a frame could not be read.";
723+
719724
throw new WebSocketException (msg);
720725
}
721726

722727
frame._payloadData = new PayloadData (bytes, len);
728+
723729
completed (frame);
724730
};
725731

726732
if (frame._payloadLength < 127) {
727733
stream.ReadBytesAsync ((int) exactLen, comp, error);
734+
728735
return;
729736
}
730737

0 commit comments

Comments
 (0)