Unverified Commit 0e8e25ca authored by honfika's avatar honfika Committed by GitHub

Merge pull request #616 from justcoding121/master

do not throw exception in fillbuffer (only when it called on an alrea…
parents e4d96d37 c9bbbd19
......@@ -159,6 +159,11 @@ namespace Titanium.Web.Proxy.Examples.Wpf
{
e.HttpClient.Request.KeepBody = true;
await e.GetRequestBody();
if (item == SelectedSession)
{
await Dispatcher.InvokeAsync(selectedSessionChanged);
}
}
}
......@@ -185,6 +190,10 @@ namespace Titanium.Web.Proxy.Examples.Wpf
await e.GetResponseBody();
await Dispatcher.InvokeAsync(() => { item.Update(); });
if (item == SelectedSession)
{
await Dispatcher.InvokeAsync(selectedSessionChanged);
}
}
}
}
......
using System;
using System.Diagnostics;
using System.IO;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
......@@ -450,7 +451,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
{
if (closed)
{
return false;
throw new Exception("Stream is already closed");
}
if (bufferLength > 0)
......@@ -462,17 +463,23 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
bufferPos = 0;
int readBytes = baseStream.Read(streamBuffer, bufferLength, streamBuffer.Length - bufferLength);
bool result = readBytes > 0;
if (result)
bool result = false;
try
{
OnDataRead(streamBuffer, bufferLength, readBytes);
bufferLength += readBytes;
int readBytes = baseStream.Read(streamBuffer, bufferLength, streamBuffer.Length - bufferLength);
result = readBytes > 0;
if (result)
{
OnDataRead(streamBuffer, bufferLength, readBytes);
bufferLength += readBytes;
}
}
else
finally
{
closed = true;
throw new EndOfStreamException();
if (!result)
{
closed = true;
}
}
return result;
......@@ -488,7 +495,7 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
{
if (closed)
{
return false;
throw new Exception("Stream is already closed");
}
if (bufferLength > 0)
......@@ -506,18 +513,23 @@ namespace Titanium.Web.Proxy.StreamExtended.Network
bufferPos = 0;
int readBytes = await baseStream.ReadAsync(streamBuffer, bufferLength, bytesToRead, cancellationToken);
bool result = readBytes > 0;
if (result)
bool result = false;
try
{
OnDataRead(streamBuffer, bufferLength, readBytes);
bufferLength += readBytes;
int readBytes = await baseStream.ReadAsync(streamBuffer, bufferLength, bytesToRead, cancellationToken);
result = readBytes > 0;
if (result)
{
OnDataRead(streamBuffer, bufferLength, readBytes);
bufferLength += readBytes;
}
}
else
finally
{
closed = true;
// do not throw exception here
if (!result)
{
closed = true;
}
}
return result;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment