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

Commit ae9e850

Browse files
Merge pull request #581 from honfika/master
typo fixes, add some missing xml comment for method arguments, fix the wpf test project (invalid cast exception)
2 parents 7b792b3 + 1d038a3 commit ae9e850

31 files changed

+127
-122
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
namespace Titanium.Web.Proxy.Examples.Basic.Helpers
55
{
66
/// <summary>
7-
/// Adapated from
7+
/// Adapted from
88
/// http://stackoverflow.com/questions/13656846/how-to-programmatic-disable-c-sharp-console-applications-quick-edit-mode
99
/// </summary>
1010
internal static class ConsoleHelper

examples/Titanium.Web.Proxy.Examples.Basic/ProxyTestController.cs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ public ProxyTestController()
3232
{
3333
if (exception is ProxyHttpException phex)
3434
{
35-
await WriteToConsole(exception.Message + ": " + phex.InnerException?.Message, true);
35+
await writeToConsole(exception.Message + ": " + phex.InnerException?.Message, true);
3636
}
3737
else
3838
{
39-
await WriteToConsole(exception.Message, true);
39+
await writeToConsole(exception.Message, true);
4040
}
4141
};
4242
proxyServer.ForwardToUpstreamGateway = true;
@@ -52,8 +52,8 @@ public ProxyTestController()
5252

5353
public void StartProxy()
5454
{
55-
proxyServer.BeforeRequest += OnRequest;
56-
proxyServer.BeforeResponse += OnResponse;
55+
proxyServer.BeforeRequest += onRequest;
56+
proxyServer.BeforeResponse += onResponse;
5757

5858
proxyServer.ServerCertificateValidationCallback += OnCertificateValidation;
5959
proxyServer.ClientCertificateSelectionCallback += OnCertificateSelection;
@@ -63,8 +63,8 @@ public void StartProxy()
6363
explicitEndPoint = new ExplicitProxyEndPoint(IPAddress.Any, 8000);
6464

6565
// Fired when a CONNECT request is received
66-
explicitEndPoint.BeforeTunnelConnectRequest += OnBeforeTunnelConnectRequest;
67-
explicitEndPoint.BeforeTunnelConnectResponse += OnBeforeTunnelConnectResponse;
66+
explicitEndPoint.BeforeTunnelConnectRequest += onBeforeTunnelConnectRequest;
67+
explicitEndPoint.BeforeTunnelConnectResponse += onBeforeTunnelConnectResponse;
6868

6969
// An explicit endpoint is where the client knows about the existence of a proxy
7070
// So client sends request in a proxy friendly manner
@@ -102,11 +102,11 @@ public void StartProxy()
102102

103103
public void Stop()
104104
{
105-
explicitEndPoint.BeforeTunnelConnectRequest -= OnBeforeTunnelConnectRequest;
106-
explicitEndPoint.BeforeTunnelConnectResponse -= OnBeforeTunnelConnectResponse;
105+
explicitEndPoint.BeforeTunnelConnectRequest -= onBeforeTunnelConnectRequest;
106+
explicitEndPoint.BeforeTunnelConnectResponse -= onBeforeTunnelConnectResponse;
107107

108-
proxyServer.BeforeRequest -= OnRequest;
109-
proxyServer.BeforeResponse -= OnResponse;
108+
proxyServer.BeforeRequest -= onRequest;
109+
proxyServer.BeforeResponse -= onResponse;
110110
proxyServer.ServerCertificateValidationCallback -= OnCertificateValidation;
111111
proxyServer.ClientCertificateSelectionCallback -= OnCertificateSelection;
112112

@@ -116,10 +116,10 @@ public void Stop()
116116
//proxyServer.CertificateManager.RemoveTrustedRootCertificates();
117117
}
118118

119-
private async Task OnBeforeTunnelConnectRequest(object sender, TunnelConnectSessionEventArgs e)
119+
private async Task onBeforeTunnelConnectRequest(object sender, TunnelConnectSessionEventArgs e)
120120
{
121121
string hostname = e.HttpClient.Request.RequestUri.Host;
122-
await WriteToConsole("Tunnel to: " + hostname);
122+
await writeToConsole("Tunnel to: " + hostname);
123123

124124
if (hostname.Contains("dropbox.com"))
125125
{
@@ -130,16 +130,16 @@ private async Task OnBeforeTunnelConnectRequest(object sender, TunnelConnectSess
130130
}
131131
}
132132

133-
private Task OnBeforeTunnelConnectResponse(object sender, TunnelConnectSessionEventArgs e)
133+
private Task onBeforeTunnelConnectResponse(object sender, TunnelConnectSessionEventArgs e)
134134
{
135135
return Task.FromResult(false);
136136
}
137137

138138
// intecept & cancel redirect or update requests
139-
private async Task OnRequest(object sender, SessionEventArgs e)
139+
private async Task onRequest(object sender, SessionEventArgs e)
140140
{
141-
await WriteToConsole("Active Client Connections:" + ((ProxyServer)sender).ClientConnectionCount);
142-
await WriteToConsole(e.HttpClient.Request.Url);
141+
await writeToConsole("Active Client Connections:" + ((ProxyServer)sender).ClientConnectionCount);
142+
await writeToConsole(e.HttpClient.Request.Url);
143143

144144
// store it in the UserData property
145145
// It can be a simple integer, Guid, or any type
@@ -177,19 +177,19 @@ private async Task OnRequest(object sender, SessionEventArgs e)
177177
}
178178

179179
// Modify response
180-
private async Task MultipartRequestPartSent(object sender, MultipartRequestPartSentEventArgs e)
180+
private async Task multipartRequestPartSent(object sender, MultipartRequestPartSentEventArgs e)
181181
{
182182
var session = (SessionEventArgs)sender;
183-
await WriteToConsole("Multipart form data headers:");
183+
await writeToConsole("Multipart form data headers:");
184184
foreach (var header in e.Headers)
185185
{
186-
await WriteToConsole(header.ToString());
186+
await writeToConsole(header.ToString());
187187
}
188188
}
189189

190-
private async Task OnResponse(object sender, SessionEventArgs e)
190+
private async Task onResponse(object sender, SessionEventArgs e)
191191
{
192-
await WriteToConsole("Active Server Connections:" + ((ProxyServer)sender).ServerConnectionCount);
192+
await writeToConsole("Active Server Connections:" + ((ProxyServer)sender).ServerConnectionCount);
193193

194194
string ext = System.IO.Path.GetExtension(e.HttpClient.Request.RequestUri.AbsolutePath);
195195

@@ -261,7 +261,7 @@ public Task OnCertificateSelection(object sender, CertificateSelectionEventArgs
261261
return Task.FromResult(0);
262262
}
263263

264-
private async Task WriteToConsole(string message, bool useRedColor = false)
264+
private async Task writeToConsole(string message, bool useRedColor = false)
265265
{
266266
await @lock.WaitAsync();
267267

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public SessionListItem SelectedSession
106106
if (value != selectedSession)
107107
{
108108
selectedSession = value;
109-
SelectedSessionChanged();
109+
selectedSessionChanged();
110110
}
111111
}
112112
}
@@ -131,7 +131,7 @@ private async Task ProxyServer_BeforeTunnelConnectRequest(object sender, TunnelC
131131
e.DecryptSsl = false;
132132
}
133133

134-
await Dispatcher.InvokeAsync(() => { AddSession(e); });
134+
await Dispatcher.InvokeAsync(() => { addSession(e); });
135135
}
136136

137137
private async Task ProxyServer_BeforeTunnelConnectResponse(object sender, TunnelConnectSessionEventArgs e)
@@ -148,7 +148,7 @@ await Dispatcher.InvokeAsync(() =>
148148
private async Task ProxyServer_BeforeRequest(object sender, SessionEventArgs e)
149149
{
150150
SessionListItem item = null;
151-
await Dispatcher.InvokeAsync(() => { item = AddSession(e); });
151+
await Dispatcher.InvokeAsync(() => { item = addSession(e); });
152152

153153
if (e.HttpClient.Request.HasBody)
154154
{
@@ -191,15 +191,15 @@ await Dispatcher.InvokeAsync(() =>
191191
});
192192
}
193193

194-
private SessionListItem AddSession(SessionEventArgsBase e)
194+
private SessionListItem addSession(SessionEventArgsBase e)
195195
{
196-
var item = CreateSessionListItem(e);
196+
var item = createSessionListItem(e);
197197
Sessions.Add(item);
198198
sessionDictionary.Add(e.HttpClient, item);
199199
return item;
200200
}
201201

202-
private SessionListItem CreateSessionListItem(SessionEventArgsBase e)
202+
private SessionListItem createSessionListItem(SessionEventArgsBase e)
203203
{
204204
lastSessionNumber++;
205205
bool isTunnelConnect = e is TunnelConnectSessionEventArgs;
@@ -214,7 +214,7 @@ private SessionListItem CreateSessionListItem(SessionEventArgsBase e)
214214
{
215215
e.DataReceived += (sender, args) =>
216216
{
217-
var session = (SessionEventArgs)sender;
217+
var session = (SessionEventArgsBase)sender;
218218
if (sessionDictionary.TryGetValue(session.HttpClient, out var li))
219219
{
220220
li.ReceivedDataCount += args.Count;
@@ -223,7 +223,7 @@ private SessionListItem CreateSessionListItem(SessionEventArgsBase e)
223223

224224
e.DataSent += (sender, args) =>
225225
{
226-
var session = (SessionEventArgs)sender;
226+
var session = (SessionEventArgsBase)sender;
227227
if (sessionDictionary.TryGetValue(session.HttpClient, out var li))
228228
{
229229
li.SentDataCount += args.Count;
@@ -248,7 +248,7 @@ private void ListViewSessions_OnKeyDown(object sender, KeyEventArgs e)
248248
}
249249
}
250250

251-
private void SelectedSessionChanged()
251+
private void selectedSessionChanged()
252252
{
253253
if (SelectedSession == null)
254254
{

examples/Titanium.Web.Proxy.Examples.Wpf/Properties/Annotations.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public sealed class NotNullAttribute : Attribute
7373
}
7474

7575
/// <summary>
76-
/// Can be appplied to symbols of types derived from IEnumerable as well as to symbols of Task
76+
/// Can be applied to symbols of types derived from IEnumerable as well as to symbols of Task
7777
/// and Lazy classes to indicate that the value of a collection item, of the Task.Result property
7878
/// or of the Lazy.Value property can never be null.
7979
/// </summary>
@@ -85,7 +85,7 @@ public sealed class ItemNotNullAttribute : Attribute
8585
}
8686

8787
/// <summary>
88-
/// Can be appplied to symbols of types derived from IEnumerable as well as to symbols of Task
88+
/// Can be applied to symbols of types derived from IEnumerable as well as to symbols of Task
8989
/// and Lazy classes to indicate that the value of a collection item, of the Task.Result property
9090
/// or of the Lazy.Value property can be null.
9191
/// </summary>
@@ -251,7 +251,7 @@ public NotifyPropertyChangedInvocatorAttribute([NotNull] string parameterName)
251251
/// </list>
252252
/// If method has single input parameter, it's name could be omitted.<br />
253253
/// Using <c>halt</c> (or <c>void</c>/<c>nothing</c>, which is the same) for method output
254-
/// means that the methos doesn't return normally (throws or terminates the process).<br />
254+
/// means that the method doesn't return normally (throws or terminates the process).<br />
255255
/// Value <c>canbenull</c> is only applicable for output parameters.<br />
256256
/// You can use multiple <c>[ContractAnnotation]</c> for each FDT row, or use single attribute
257257
/// with rows separated by semicolon. There is no notion of order rows, all rows are checked

src/Titanium.Web.Proxy.sln.DotSettings

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,19 @@
1919
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=MTA/@EntryIndexedValue">MTA</s:String>
2020
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=OID/@EntryIndexedValue">OID</s:String>
2121
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=OIDS/@EntryIndexedValue">OIDS</s:String>
22+
<s:Boolean x:Key="/Default/CodeStyle/Naming/CSharpNaming/ApplyAutoDetectedRules/@EntryValue">False</s:Boolean>
2223
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateConstants/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
2324
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
2425
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
2526
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticReadonly/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
27+
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PublicFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
2628
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=a4ab2e69_002D4d9c_002D4345_002Dbcd1_002D5541dacf5d38/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Static, Instance" AccessRightKinds="Private" Description="Method (private)"&gt;&lt;ElementKinds&gt;&lt;Kind Name="METHOD" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;&lt;/Policy&gt;</s:String>
2729
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=dda2ffa1_002D435c_002D4111_002D88eb_002D1a7c93c382f0/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Static, Instance" AccessRightKinds="Private" Description="Property (private)"&gt;&lt;ElementKinds&gt;&lt;Kind Name="PROPERTY" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;&lt;/Policy&gt;</s:String>
2830
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpAttributeForSingleLineMethodUpgrade/@EntryIndexedValue">True</s:Boolean>
2931
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpKeepExistingMigration/@EntryIndexedValue">True</s:Boolean>
3032
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
3133
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpRenamePlacementToArrangementMigration/@EntryIndexedValue">True</s:Boolean>
34+
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpUseContinuousIndentInsideBracesMigration/@EntryIndexedValue">True</s:Boolean>
3235
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EAddAccessorOwnerDeclarationBracesMigration/@EntryIndexedValue">True</s:Boolean>
3336
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002ECSharpPlaceAttributeOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
3437
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>

src/Titanium.Web.Proxy/EventArguments/CertificateSelectionEventArgs.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class CertificateSelectionEventArgs : EventArgs
2929
public X509Certificate RemoteCertificate { get; internal set; }
3030

3131
/// <summary>
32-
/// Acceptable issuers as listed by remoted server.
32+
/// Acceptable issuers as listed by remote server.
3333
/// </summary>
3434
public string[] AcceptableIssuers { get; internal set; }
3535

src/Titanium.Web.Proxy/EventArguments/SessionEventArgs.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ internal void OnMultipartRequestPartSent(string boundary, HeaderCollection heade
117117
}
118118
catch (Exception ex)
119119
{
120-
exceptionFunc(new Exception("Exception thrown in user event", ex));
120+
ExceptionFunc(new Exception("Exception thrown in user event", ex));
121121
}
122122
}
123123

@@ -154,7 +154,7 @@ private async Task<byte[]> readBodyAsync(bool isRequest, CancellationToken cance
154154
{
155155
using (var bodyStream = new MemoryStream())
156156
{
157-
var writer = new HttpWriter(bodyStream, bufferPool, bufferSize);
157+
var writer = new HttpWriter(bodyStream, BufferPool, BufferSize);
158158

159159
if (isRequest)
160160
{
@@ -186,7 +186,7 @@ internal async Task SyphonOutBodyAsync(bool isRequest, CancellationToken cancell
186186

187187
using (var bodyStream = new MemoryStream())
188188
{
189-
var writer = new HttpWriter(bodyStream, bufferPool, bufferSize);
189+
var writer = new HttpWriter(bodyStream, BufferPool, BufferSize);
190190
await copyBodyAsync(isRequest, true, writer, TransformationMode.None, null, cancellationToken);
191191
}
192192
}
@@ -207,7 +207,7 @@ internal async Task CopyRequestBodyAsync(HttpWriter writer, TransformationMode t
207207
var reader = getStreamReader(true);
208208
string boundary = HttpHelper.GetBoundaryFromContentType(request.ContentType);
209209

210-
using (var copyStream = new CopyStream(reader, writer, bufferPool, bufferSize))
210+
using (var copyStream = new CopyStream(reader, writer, BufferPool, BufferSize))
211211
{
212212
while (contentLength > copyStream.ReadBytes)
213213
{
@@ -259,7 +259,7 @@ private async Task copyBodyAsync(bool isRequest, bool useOriginalHeaderValues, H
259259

260260
string contentEncoding = useOriginalHeaderValues ? requestResponse.OriginalContentEncoding : requestResponse.ContentEncoding;
261261

262-
Stream s = limitedStream = new LimitedStream(stream, bufferPool, isChunked, contentLength);
262+
Stream s = limitedStream = new LimitedStream(stream, BufferPool, isChunked, contentLength);
263263

264264
if (transformation == TransformationMode.Uncompress && contentEncoding != null)
265265
{
@@ -268,7 +268,7 @@ private async Task copyBodyAsync(bool isRequest, bool useOriginalHeaderValues, H
268268

269269
try
270270
{
271-
using (var bufStream = new CustomBufferedStream(s, bufferPool, bufferSize, true))
271+
using (var bufStream = new CustomBufferedStream(s, BufferPool, BufferSize, true))
272272
{
273273
await writer.CopyBodyAsync(bufStream, false, -1, onCopy, cancellationToken);
274274
}
@@ -290,7 +290,7 @@ private async Task<long> readUntilBoundaryAsync(ICustomStreamReader reader, long
290290
{
291291
int bufferDataLength = 0;
292292

293-
var buffer = bufferPool.GetBuffer(bufferSize);
293+
var buffer = BufferPool.GetBuffer(BufferSize);
294294
try
295295
{
296296
int boundaryLength = boundary.Length + 4;
@@ -340,7 +340,7 @@ private async Task<long> readUntilBoundaryAsync(ICustomStreamReader reader, long
340340
}
341341
finally
342342
{
343-
bufferPool.ReturnBuffer(buffer);
343+
BufferPool.ReturnBuffer(buffer);
344344
}
345345
}
346346

0 commit comments

Comments
 (0)