Skip to content
This repository was archived by the owner on Jul 9, 2023. It is now read-only.

Commit 7a44e45

Browse files
authored
Merge pull request #348 from justcoding121/develop
beta|develop
2 parents 8337761 + 46a0b97 commit 7a44e45

31 files changed

+277
-190
lines changed

Examples/Titanium.Web.Proxy.Examples.Basic/Helpers/ConsoleHelper.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ internal static bool DisableQuickEditMode()
2828
var consoleHandle = GetStdHandle(STD_INPUT_HANDLE);
2929

3030
// get current console mode
31-
uint consoleMode;
32-
if (!GetConsoleMode(consoleHandle, out consoleMode))
31+
if (!GetConsoleMode(consoleHandle, out uint consoleMode))
3332
{
3433
// ERROR: Unable to get console mode.
3534
return false;

Examples/Titanium.Web.Proxy.Examples.Wpf/MainWindow.xaml.cs

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public partial class MainWindow : Window
2828

2929
public SessionListItem SelectedSession
3030
{
31-
get { return selectedSession; }
31+
get => selectedSession;
3232
set
3333
{
3434
if (value != selectedSession)
@@ -44,17 +44,17 @@ public SessionListItem SelectedSession
4444

4545
public int ClientConnectionCount
4646
{
47-
get { return (int)GetValue(ClientConnectionCountProperty); }
48-
set { SetValue(ClientConnectionCountProperty, value); }
47+
get => (int)GetValue(ClientConnectionCountProperty);
48+
set => SetValue(ClientConnectionCountProperty, value);
4949
}
5050

5151
public static readonly DependencyProperty ServerConnectionCountProperty = DependencyProperty.Register(
5252
nameof(ServerConnectionCount), typeof(int), typeof(MainWindow), new PropertyMetadata(default(int)));
5353

5454
public int ServerConnectionCount
5555
{
56-
get { return (int)GetValue(ServerConnectionCountProperty); }
57-
set { SetValue(ServerConnectionCountProperty, value); }
56+
get => (int)GetValue(ServerConnectionCountProperty);
57+
set => SetValue(ServerConnectionCountProperty, value);
5858
}
5959

6060
private readonly Dictionary<HttpWebClient, SessionListItem> sessionDictionary = new Dictionary<HttpWebClient, SessionListItem>();
@@ -107,8 +107,7 @@ private async Task ProxyServer_TunnelConnectResponse(object sender, SessionEvent
107107
{
108108
await Dispatcher.InvokeAsync(() =>
109109
{
110-
SessionListItem item;
111-
if (sessionDictionary.TryGetValue(e.WebSession, out item))
110+
if (sessionDictionary.TryGetValue(e.WebSession, out var item))
112111
{
113112
item.Update();
114113
}
@@ -135,8 +134,7 @@ private async Task ProxyServer_BeforeResponse(object sender, SessionEventArgs e)
135134
SessionListItem item = null;
136135
await Dispatcher.InvokeAsync(() =>
137136
{
138-
SessionListItem item2;
139-
if (sessionDictionary.TryGetValue(e.WebSession, out item2))
137+
if (sessionDictionary.TryGetValue(e.WebSession, out var item2))
140138
{
141139
item2.Update();
142140
item = item2;
@@ -177,8 +175,7 @@ private SessionListItem CreateSessionListItem(SessionEventArgs e)
177175
e.DataReceived += (sender, args) =>
178176
{
179177
var session = (SessionEventArgs)sender;
180-
SessionListItem li;
181-
if (sessionDictionary.TryGetValue(session.WebSession, out li))
178+
if (sessionDictionary.TryGetValue(session.WebSession, out var li))
182179
{
183180
li.ReceivedDataCount += args.Count;
184181
}
@@ -187,8 +184,7 @@ private SessionListItem CreateSessionListItem(SessionEventArgs e)
187184
e.DataSent += (sender, args) =>
188185
{
189186
var session = (SessionEventArgs)sender;
190-
SessionListItem li;
191-
if (sessionDictionary.TryGetValue(session.WebSession, out li))
187+
if (sessionDictionary.TryGetValue(session.WebSession, out var li))
192188
{
193189
li.SentDataCount += args.Count;
194190
}

Examples/Titanium.Web.Proxy.Examples.Wpf/SessionListItem.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,50 +26,50 @@ public class SessionListItem : INotifyPropertyChanged
2626

2727
public string StatusCode
2828
{
29-
get { return statusCode; }
30-
set { SetField(ref statusCode, value);}
29+
get => statusCode;
30+
set => SetField(ref statusCode, value);
3131
}
3232

3333
public string Protocol
3434
{
35-
get { return protocol; }
36-
set { SetField(ref protocol, value); }
35+
get => protocol;
36+
set => SetField(ref protocol, value);
3737
}
3838

3939
public string Host
4040
{
41-
get { return host; }
42-
set { SetField(ref host, value); }
41+
get => host;
42+
set => SetField(ref host, value);
4343
}
4444

4545
public string Url
4646
{
47-
get { return url; }
48-
set { SetField(ref url, value); }
47+
get => url;
48+
set => SetField(ref url, value);
4949
}
5050

5151
public long BodySize
5252
{
53-
get { return bodySize; }
54-
set { SetField(ref bodySize, value); }
53+
get => bodySize;
54+
set => SetField(ref bodySize, value);
5555
}
5656

5757
public string Process
5858
{
59-
get { return process; }
60-
set { SetField(ref process, value); }
59+
get => process;
60+
set => SetField(ref process, value);
6161
}
6262

6363
public long ReceivedDataCount
6464
{
65-
get { return receivedDataCount; }
66-
set { SetField(ref receivedDataCount, value); }
65+
get => receivedDataCount;
66+
set => SetField(ref receivedDataCount, value);
6767
}
6868

6969
public long SentDataCount
7070
{
71-
get { return sentDataCount; }
72-
set { SetField(ref sentDataCount, value); }
71+
get => sentDataCount;
72+
set => SetField(ref sentDataCount, value);
7373
}
7474

7575
public event PropertyChangedEventHandler PropertyChanged;

Examples/Titanium.Web.Proxy.Examples.Wpf/Titanium.Web.Proxy.Examples.Wpf.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@
5151
<WarningLevel>4</WarningLevel>
5252
</PropertyGroup>
5353
<ItemGroup>
54-
<Reference Include="StreamExtended, Version=1.0.81.0, Culture=neutral, PublicKeyToken=bbfa0f1d54f50043, processorArchitecture=MSIL">
55-
<HintPath>..\..\packages\StreamExtended.1.0.81\lib\net45\StreamExtended.dll</HintPath>
54+
<Reference Include="StreamExtended, Version=1.0.110.0, Culture=neutral, PublicKeyToken=bbfa0f1d54f50043, processorArchitecture=MSIL">
55+
<HintPath>..\..\packages\StreamExtended.1.0.110-beta\lib\net45\StreamExtended.dll</HintPath>
5656
</Reference>
5757
<Reference Include="System" />
5858
<Reference Include="System.Data" />
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="StreamExtended" version="1.0.81" targetFramework="net45" />
3+
<package id="StreamExtended" version="1.0.110-beta" targetFramework="net45" />
44
</packages>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System;
2+
using Titanium.Web.Proxy.Http;
3+
4+
namespace Titanium.Web.Proxy.EventArguments
5+
{
6+
public class MultipartRequestPartSentEventArgs : EventArgs
7+
{
8+
public string Boundary { get; }
9+
10+
public HeaderCollection Headers { get; }
11+
12+
public MultipartRequestPartSentEventArgs(string boundary, HeaderCollection headers)
13+
{
14+
Boundary = boundary;
15+
Headers = headers;
16+
}
17+
}
18+
}

Titanium.Web.Proxy/EventArguments/SessionEventArgs.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System.Net;
55
using System.Threading.Tasks;
66
using Titanium.Web.Proxy.Decompression;
7-
using Titanium.Web.Proxy.Exceptions;
87
using Titanium.Web.Proxy.Extensions;
98
using Titanium.Web.Proxy.Helpers;
109
using Titanium.Web.Proxy.Http;
@@ -42,6 +41,8 @@ public class SessionEventArgs : EventArgs, IDisposable
4241
/// </summary>
4342
internal ProxyClient ProxyClient { get; set; }
4443

44+
internal bool HasMulipartEventSubscribers => MultipartRequestPartSent != null;
45+
4546
/// <summary>
4647
/// Returns a unique Id for this request/response session
4748
/// same as RequestId of WebSession
@@ -53,7 +54,7 @@ public class SessionEventArgs : EventArgs, IDisposable
5354
/// </summary>
5455
public bool ReRequest
5556
{
56-
get { return reRequest; }
57+
get => reRequest;
5758
set
5859
{
5960
if (WebSession.Response.StatusCode == 0)
@@ -90,6 +91,11 @@ public bool ReRequest
9091

9192
public event EventHandler<DataEventArgs> DataReceived;
9293

94+
/// <summary>
95+
/// Occurs when multipart request part sent.
96+
/// </summary>
97+
public event EventHandler<MultipartRequestPartSentEventArgs> MultipartRequestPartSent;
98+
9399
public ProxyEndPoint LocalEndPoint;
94100

95101
/// <summary>
@@ -189,6 +195,11 @@ internal void OnDataReceived(byte[] buffer, int offset, int count)
189195
DataReceived?.Invoke(this, new DataEventArgs(buffer, offset, count));
190196
}
191197

198+
internal void OnMultipartRequestPartSent(string boundary, HeaderCollection headers)
199+
{
200+
MultipartRequestPartSent?.Invoke(this, new MultipartRequestPartSentEventArgs(boundary, headers));
201+
}
202+
192203
/// <summary>
193204
/// Read response body as byte[] for current response
194205
/// </summary>

Titanium.Web.Proxy/EventArguments/TunnelConnectEventArgs.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System.Net;
2-
using Titanium.Web.Proxy.Http;
1+
using Titanium.Web.Proxy.Http;
32
using Titanium.Web.Proxy.Models;
43

54
namespace Titanium.Web.Proxy.EventArguments

Titanium.Web.Proxy/Extensions/HttpWebRequestExtensions.cs

Lines changed: 0 additions & 22 deletions
This file was deleted.

Titanium.Web.Proxy/Extensions/HttpWebResponseExtensions.cs

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)