[Modify] Polish it
This commit is contained in:
parent
642dd28b61
commit
db7203aa0b
@ -221,13 +221,17 @@ namespace WebSocketSharp.Net
|
|||||||
return InputChunkState.Data;
|
return InputChunkState.Data;
|
||||||
}
|
}
|
||||||
|
|
||||||
private InputChunkState setTrailer (byte[] buffer, ref int offset, int length)
|
private InputChunkState setTrailer (
|
||||||
|
byte[] buffer, ref int offset, int length
|
||||||
|
)
|
||||||
{
|
{
|
||||||
// Check if no trailer.
|
// Check if no trailer.
|
||||||
if (_trailerState == 2 && buffer[offset] == 13 && _saved.Length == 0) {
|
if (_trailerState == 2 && buffer[offset] == 13 && _saved.Length == 0) {
|
||||||
offset++;
|
offset++;
|
||||||
|
|
||||||
if (offset < length && buffer[offset] == 10) {
|
if (offset < length && buffer[offset] == 10) {
|
||||||
offset++;
|
offset++;
|
||||||
|
|
||||||
return InputChunkState.End;
|
return InputChunkState.End;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,6 +241,7 @@ namespace WebSocketSharp.Net
|
|||||||
while (offset < length && _trailerState < 4) {
|
while (offset < length && _trailerState < 4) {
|
||||||
var b = buffer[offset++];
|
var b = buffer[offset++];
|
||||||
_saved.Append ((char) b);
|
_saved.Append ((char) b);
|
||||||
|
|
||||||
if (_saved.Length > 4196)
|
if (_saved.Length > 4196)
|
||||||
throwProtocolViolation ("The trailer is too long.");
|
throwProtocolViolation ("The trailer is too long.");
|
||||||
|
|
||||||
@ -245,11 +250,13 @@ namespace WebSocketSharp.Net
|
|||||||
throwProtocolViolation ("LF is expected.");
|
throwProtocolViolation ("LF is expected.");
|
||||||
|
|
||||||
_trailerState++;
|
_trailerState++;
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (b == 13) {
|
if (b == 13) {
|
||||||
_trailerState++;
|
_trailerState++;
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,9 +272,14 @@ namespace WebSocketSharp.Net
|
|||||||
_saved.Length -= 2;
|
_saved.Length -= 2;
|
||||||
var reader = new StringReader (_saved.ToString ());
|
var reader = new StringReader (_saved.ToString ());
|
||||||
|
|
||||||
string line;
|
while (true) {
|
||||||
while ((line = reader.ReadLine ()) != null && line.Length > 0)
|
var line = reader.ReadLine ();
|
||||||
|
|
||||||
|
if (line == null || line.Length == 0)
|
||||||
|
break;
|
||||||
|
|
||||||
_headers.Add (line);
|
_headers.Add (line);
|
||||||
|
}
|
||||||
|
|
||||||
return InputChunkState.End;
|
return InputChunkState.End;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user