Fix a few for WsStream.cs

This commit is contained in:
sta 2014-04-14 17:34:40 +09:00
parent 9358f5b2e2
commit 87068bc4f3

View File

@ -182,8 +182,7 @@ namespace WebSocketSharp
return new WsStream (conn.Stream, conn.IsSecure); return new WsStream (conn.Stream, conn.IsSecure);
} }
internal T ReadHandshake<T> ( internal T ReadHandshake<T> (Func<string [], T> parser, int millisecondsTimeout)
Func<string [], T> parser, int millisecondsTimeout)
where T : HandshakeBase where T : HandshakeBase
{ {
var timeout = false; var timeout = false;
@ -202,8 +201,7 @@ namespace WebSocketSharp
handshake = parser (readHandshakeHeaders (_innerStream)); handshake = parser (readHandshakeHeaders (_innerStream));
var contentLen = handshake.Headers ["Content-Length"]; var contentLen = handshake.Headers ["Content-Length"];
if (contentLen != null && contentLen.Length > 0) if (contentLen != null && contentLen.Length > 0)
handshake.EntityBodyData = readHandshakeEntityBody ( handshake.EntityBodyData = readHandshakeEntityBody (_innerStream, contentLen);
_innerStream, contentLen);
} }
catch (Exception ex) { catch (Exception ex) {
exception = ex; exception = ex;
@ -213,14 +211,14 @@ namespace WebSocketSharp
timer.Dispose (); timer.Dispose ();
} }
var reason = timeout var msg = timeout
? "A timeout has occurred while receiving a handshake." ? "A timeout has occurred while receiving a handshake."
: exception != null : exception != null
? "An exception has occurred while receiving a handshake." ? "An exception has occurred while receiving a handshake."
: null; : null;
if (reason != null) if (msg != null)
throw new WebSocketException (reason, exception); throw new WebSocketException (msg, exception);
return handshake; return handshake;
} }
@ -257,8 +255,7 @@ namespace WebSocketSharp
return WsFrame.Parse (_innerStream, true); return WsFrame.Parse (_innerStream, true);
} }
public void ReadFrameAsync ( public void ReadFrameAsync (Action<WsFrame> completed, Action<Exception> error)
Action<WsFrame> completed, Action<Exception> error)
{ {
WsFrame.ParseAsync (_innerStream, true, completed, error); WsFrame.ParseAsync (_innerStream, true, completed, error);
} }