[Modify] Polish it

This commit is contained in:
sta 2020-10-30 19:39:20 +09:00
parent 2548f5e202
commit 1a693a8502

View File

@ -372,10 +372,13 @@ namespace WebSocketSharp.Net
_currentLine = new StringBuilder (64); _currentLine = new StringBuilder (64);
var nread = 0; var nread = 0;
try { try {
string line; string line;
while ((line = readLineFrom (data, _position, length, out nread)) != null) { while ((line = readLineFrom (data, _position, length, out nread)) != null) {
_position += nread; _position += nread;
if (line.Length == 0) { if (line.Length == 0) {
if (_inputState == InputState.RequestLine) if (_inputState == InputState.RequestLine)
continue; continue;
@ -384,6 +387,7 @@ namespace WebSocketSharp.Net
_context.ErrorMessage = "Headers too long"; _context.ErrorMessage = "Headers too long";
_currentLine = null; _currentLine = null;
return true; return true;
} }
@ -401,12 +405,15 @@ namespace WebSocketSharp.Net
} }
catch (Exception ex) { catch (Exception ex) {
_context.ErrorMessage = ex.Message; _context.ErrorMessage = ex.Message;
return true; return true;
} }
_position += nread; _position += nread;
if (_position >= 32768) { if (_position >= 32768) {
_context.ErrorMessage = "Headers too long"; _context.ErrorMessage = "Headers too long";
return true; return true;
} }