Commit 9927f5b6 authored by Honfika's avatar Honfika

budy size fixed in wpf demo app

parent 6e10c893
...@@ -11,7 +11,6 @@ using Titanium.Web.Proxy.EventArguments; ...@@ -11,7 +11,6 @@ using Titanium.Web.Proxy.EventArguments;
using Titanium.Web.Proxy.Helpers; using Titanium.Web.Proxy.Helpers;
using Titanium.Web.Proxy.Http; using Titanium.Web.Proxy.Http;
using Titanium.Web.Proxy.Models; using Titanium.Web.Proxy.Models;
using Titanium.Web.Proxy.Network;
namespace Titanium.Web.Proxy.Examples.Wpf namespace Titanium.Web.Proxy.Examples.Wpf
{ {
...@@ -135,10 +134,9 @@ namespace Titanium.Web.Proxy.Examples.Wpf ...@@ -135,10 +134,9 @@ namespace Titanium.Web.Proxy.Examples.Wpf
SessionListItem item = null; SessionListItem item = null;
await Dispatcher.InvokeAsync(() => await Dispatcher.InvokeAsync(() =>
{ {
if (sessionDictionary.TryGetValue(e.WebSession, out var item2)) if (sessionDictionary.TryGetValue(e.WebSession, out item))
{ {
item2.Update(); item.Update();
item = item2;
} }
}); });
...@@ -148,6 +146,11 @@ namespace Titanium.Web.Proxy.Examples.Wpf ...@@ -148,6 +146,11 @@ namespace Titanium.Web.Proxy.Examples.Wpf
{ {
e.WebSession.Response.KeepBody = true; e.WebSession.Response.KeepBody = true;
await e.GetResponseBody(); await e.GetResponseBody();
await Dispatcher.InvokeAsync(() =>
{
item.Update();
});
} }
} }
} }
......
...@@ -13,7 +13,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf ...@@ -13,7 +13,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
private string protocol; private string protocol;
private string host; private string host;
private string url; private string url;
private long bodySize; private long? bodySize;
private string process; private string process;
private long receivedDataCount; private long receivedDataCount;
private long sentDataCount; private long sentDataCount;
...@@ -48,7 +48,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf ...@@ -48,7 +48,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
set => SetField(ref url, value); set => SetField(ref url, value);
} }
public long BodySize public long? BodySize
{ {
get => bodySize; get => bodySize;
set => SetField(ref bodySize, value); set => SetField(ref bodySize, value);
...@@ -76,8 +76,11 @@ namespace Titanium.Web.Proxy.Examples.Wpf ...@@ -76,8 +76,11 @@ namespace Titanium.Web.Proxy.Examples.Wpf
protected void SetField<T>(ref T field, T value,[CallerMemberName] string propertyName = null) protected void SetField<T>(ref T field, T value,[CallerMemberName] string propertyName = null)
{ {
field = value; if (!Equals(field, value))
OnPropertyChanged(propertyName); {
field = value;
OnPropertyChanged(propertyName);
}
} }
[NotifyPropertyChangedInvocator] [NotifyPropertyChangedInvocator]
...@@ -105,7 +108,24 @@ namespace Titanium.Web.Proxy.Examples.Wpf ...@@ -105,7 +108,24 @@ namespace Titanium.Web.Proxy.Examples.Wpf
Url = request.RequestUri.AbsolutePath; Url = request.RequestUri.AbsolutePath;
} }
BodySize = response?.ContentLength ?? -1; if (!IsTunnelConnect)
{
long responseSize = -1;
if (response != null)
{
if (response.ContentLength != -1)
{
responseSize = response.ContentLength;
}
else if (response.IsBodyRead && response.Body != null)
{
responseSize = response.Body.Length;
}
}
BodySize = responseSize;
}
Process = GetProcessDescription(WebSession.ProcessId.Value); Process = GetProcessDescription(WebSession.ProcessId.Value);
} }
......
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