[Modify] Polish it
This commit is contained in:
parent
1a693a8502
commit
a1d396490d
@ -420,31 +420,41 @@ namespace WebSocketSharp.Net
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private string readLineFrom (byte[] buffer, int offset, int length, out int read)
|
private string readLineFrom (
|
||||||
|
byte[] buffer, int offset, int length, out int read
|
||||||
|
)
|
||||||
{
|
{
|
||||||
read = 0;
|
read = 0;
|
||||||
|
|
||||||
for (var i = offset; i < length && _lineState != LineState.Lf; i++) {
|
for (var i = offset; i < length; i++) {
|
||||||
read++;
|
read++;
|
||||||
|
|
||||||
var b = buffer[i];
|
var b = buffer[i];
|
||||||
if (b == 13)
|
|
||||||
|
if (b == 13) {
|
||||||
_lineState = LineState.Cr;
|
_lineState = LineState.Cr;
|
||||||
else if (b == 10)
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (b == 10) {
|
||||||
_lineState = LineState.Lf;
|
_lineState = LineState.Lf;
|
||||||
else
|
|
||||||
_currentLine.Append ((char) b);
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
_currentLine.Append ((char) b);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_lineState != LineState.Lf)
|
if (_lineState != LineState.Lf)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var line = _currentLine.ToString ();
|
var ret = _currentLine.ToString ();
|
||||||
|
|
||||||
_currentLine.Length = 0;
|
_currentLine.Length = 0;
|
||||||
_lineState = LineState.None;
|
_lineState = LineState.None;
|
||||||
|
|
||||||
return line;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeConnection ()
|
private void removeConnection ()
|
||||||
|
Loading…
Reference in New Issue
Block a user