Fix for issue #84
This commit is contained in:
parent
f60f16f70f
commit
72867a26da
@ -131,16 +131,21 @@ namespace WebSocketSharp
|
|||||||
|
|
||||||
private static byte[] readBytes (this Stream stream, byte[] buffer, int offset, int length)
|
private static byte[] readBytes (this Stream stream, byte[] buffer, int offset, int length)
|
||||||
{
|
{
|
||||||
var len = stream.Read (buffer, offset, length);
|
var len = 0;
|
||||||
if (len < 1)
|
try {
|
||||||
return buffer.SubArray (0, offset);
|
len = stream.Read (buffer, offset, length);
|
||||||
|
if (len < 1)
|
||||||
|
return buffer.SubArray (0, offset);
|
||||||
|
|
||||||
while (len < length) {
|
while (len < length) {
|
||||||
var readLen = stream.Read (buffer, offset + len, length - len);
|
var readLen = stream.Read (buffer, offset + len, length - len);
|
||||||
if (readLen < 1)
|
if (readLen < 1)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
len += readLen;
|
len += readLen;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch {
|
||||||
}
|
}
|
||||||
|
|
||||||
return len < length
|
return len < length
|
||||||
@ -681,12 +686,8 @@ namespace WebSocketSharp
|
|||||||
? stream.readBytes (buff, len, length - len)
|
? stream.readBytes (buff, len, length - len)
|
||||||
: buff;
|
: buff;
|
||||||
}
|
}
|
||||||
catch (ObjectDisposedException) {
|
|
||||||
// The Stream has been closed.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
catch {
|
catch {
|
||||||
throw;
|
bytes = new byte[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (completed != null)
|
if (completed != null)
|
||||||
|
Loading…
Reference in New Issue
Block a user