[Modify] Polish it
This commit is contained in:
parent
86a473caef
commit
29cdd3b169
@ -586,23 +586,25 @@ namespace WebSocketSharp.Net
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns true is the stream could be reused.
|
|
||||||
internal bool FlushInput ()
|
internal bool FlushInput ()
|
||||||
{
|
{
|
||||||
if (!HasEntityBody)
|
if (!HasEntityBody)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
var len = 2048;
|
var len = 2048;
|
||||||
if (_contentLength > 0)
|
if (_contentLength > 0 && _contentLength < len)
|
||||||
len = (int) Math.Min (_contentLength, (long) len);
|
len = (int) _contentLength;
|
||||||
|
|
||||||
var buff = new byte[len];
|
var buff = new byte[len];
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
// TODO: Test if MS has a timeout when doing this.
|
|
||||||
try {
|
try {
|
||||||
var ares = InputStream.BeginRead (buff, 0, len, null, null);
|
var ares = InputStream.BeginRead (buff, 0, len, null, null);
|
||||||
if (!ares.IsCompleted && !ares.AsyncWaitHandle.WaitOne (100))
|
if (!ares.IsCompleted) {
|
||||||
|
var timeout = 100;
|
||||||
|
if (!ares.AsyncWaitHandle.WaitOne (timeout))
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (InputStream.EndRead (ares) <= 0)
|
if (InputStream.EndRead (ares) <= 0)
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user