[Modify] Polish it

This commit is contained in:
sta 2015-12-19 16:08:04 +09:00
parent 7d520184c8
commit 29e0d3607a

View File

@ -426,8 +426,7 @@ Extended Payload Length: {7}
private static WebSocketFrame processHeader (byte[] header)
{
if (header.Length != 2)
throw new WebSocketException (
"The header part of a frame cannot be read from the data source.");
throw new WebSocketException ("The header of a frame cannot be read from the stream.");
// FIN
var fin = (header[0] & 0x80) == 0x80 ? Fin.Final : Fin.More;
@ -450,7 +449,6 @@ Extended Payload Length: {7}
// Payload Length
var payloadLen = (byte) (header[1] & 0x7f);
// Check if valid header.
var err = !opcode.IsSupported ()
? "An unsupported opcode."
: !opcode.IsData () && rsv1 == Rsv.On
@ -487,7 +485,7 @@ Extended Payload Length: {7}
var bytes = stream.ReadBytes (len);
if (bytes.Length != len)
throw new WebSocketException (
"The 'Extended Payload Length' of a frame cannot be read from the data source.");
"The extended payload length of a frame cannot be read from the stream.");
frame._extPayloadLength = bytes;
return frame;
@ -512,7 +510,7 @@ Extended Payload Length: {7}
bytes => {
if (bytes.Length != len)
throw new WebSocketException (
"The 'Extended Payload Length' of a frame cannot be read from the data source.");
"The extended payload length of a frame cannot be read from the stream.");
frame._extPayloadLength = bytes;
completed (frame);
@ -541,8 +539,7 @@ Extended Payload Length: {7}
var bytes = stream.ReadBytes (len);
if (bytes.Length != len)
throw new WebSocketException (
"The 'Masking Key' of a frame cannot be read from the data source.");
throw new WebSocketException ("The masking key of a frame cannot be read from the stream.");
frame._maskingKey = bytes;
return frame;
@ -567,7 +564,7 @@ Extended Payload Length: {7}
bytes => {
if (bytes.Length != len)
throw new WebSocketException (
"The 'Masking Key' of a frame cannot be read from the data source.");
"The masking key of a frame cannot be read from the stream.");
frame._maskingKey = bytes;
completed (frame);
@ -583,11 +580,8 @@ Extended Payload Length: {7}
return frame;
}
// Check if allowable length.
if (len > PayloadData.MaxLength)
throw new WebSocketException (
CloseStatusCode.TooBig,
"The length of 'Payload Data' of a frame is greater than the allowable max length.");
throw new WebSocketException (CloseStatusCode.TooBig, "A frame has a long payload length.");
var llen = (long) len;
var bytes = frame._payloadLength < 127
@ -596,7 +590,7 @@ Extended Payload Length: {7}
if (bytes.LongLength != llen)
throw new WebSocketException (
"The 'Payload Data' of a frame cannot be read from the data source.");
"The payload data of a frame cannot be read from the stream.");
frame._payloadData = new PayloadData (bytes, llen);
return frame;
@ -616,17 +610,14 @@ Extended Payload Length: {7}
return;
}
// Check if allowable length.
if (len > PayloadData.MaxLength)
throw new WebSocketException (
CloseStatusCode.TooBig,
"The length of 'Payload Data' of a frame is greater than the allowable max length.");
throw new WebSocketException (CloseStatusCode.TooBig, "A frame has a long payload length.");
var llen = (long) len;
Action<byte[]> compl = bytes => {
if (bytes.LongLength != llen)
throw new WebSocketException (
"The 'Payload Data' of a frame cannot be read from the data source.");
"The payload data of a frame cannot be read from the stream.");
frame._payloadData = new PayloadData (bytes, llen);
completed (frame);