From 43efc3454298268254d8454d518a721e41db8dab Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 20 Apr 2015 14:53:31 +0900 Subject: [PATCH] Refactored a few for ChunkStream.cs --- websocket-sharp/Net/ChunkStream.cs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Net/ChunkStream.cs b/websocket-sharp/Net/ChunkStream.cs index 25b97331..df226044 100644 --- a/websocket-sharp/Net/ChunkStream.cs +++ b/websocket-sharp/Net/ChunkStream.cs @@ -159,10 +159,10 @@ namespace WebSocketSharp.Net while (offset < length) { b = buffer[offset++]; if (_sawCr) { - if (b == 10) - break; + if (b != 10) + throwProtocolViolation ("LF is expected."); - throwProtocolViolation ("LF is expected."); + break; } if (b == 13) { @@ -223,12 +223,11 @@ namespace WebSocketSharp.Net throwProtocolViolation ("The trailer is too long."); if (_trailerState == 1 || _trailerState == 3) { - if (b == 10) { - _trailerState++; - continue; - } + if (b != 10) + throwProtocolViolation ("LF is expected."); - throwProtocolViolation ("LF is expected."); + _trailerState++; + continue; } if (b == 13) {