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

typo fixes, add some missing xml comment for method arguments, fix the wpf test project (invalid cast exception) #581

Merged
merged 4 commits into from
Apr 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace Titanium.Web.Proxy.Examples.Basic.Helpers
{
/// <summary>
/// Adapated from
/// Adapted from
/// http://stackoverflow.com/questions/13656846/how-to-programmatic-disable-c-sharp-console-applications-quick-edit-mode
/// </summary>
internal static class ConsoleHelper
Expand Down
44 changes: 22 additions & 22 deletions examples/Titanium.Web.Proxy.Examples.Basic/ProxyTestController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ public ProxyTestController()
{
if (exception is ProxyHttpException phex)
{
await WriteToConsole(exception.Message + ": " + phex.InnerException?.Message, true);
await writeToConsole(exception.Message + ": " + phex.InnerException?.Message, true);
}
else
{
await WriteToConsole(exception.Message, true);
await writeToConsole(exception.Message, true);
}
};
proxyServer.ForwardToUpstreamGateway = true;
Expand All @@ -52,8 +52,8 @@ public ProxyTestController()

public void StartProxy()
{
proxyServer.BeforeRequest += OnRequest;
proxyServer.BeforeResponse += OnResponse;
proxyServer.BeforeRequest += onRequest;
proxyServer.BeforeResponse += onResponse;

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

// Fired when a CONNECT request is received
explicitEndPoint.BeforeTunnelConnectRequest += OnBeforeTunnelConnectRequest;
explicitEndPoint.BeforeTunnelConnectResponse += OnBeforeTunnelConnectResponse;
explicitEndPoint.BeforeTunnelConnectRequest += onBeforeTunnelConnectRequest;
explicitEndPoint.BeforeTunnelConnectResponse += onBeforeTunnelConnectResponse;

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

public void Stop()
{
explicitEndPoint.BeforeTunnelConnectRequest -= OnBeforeTunnelConnectRequest;
explicitEndPoint.BeforeTunnelConnectResponse -= OnBeforeTunnelConnectResponse;
explicitEndPoint.BeforeTunnelConnectRequest -= onBeforeTunnelConnectRequest;
explicitEndPoint.BeforeTunnelConnectResponse -= onBeforeTunnelConnectResponse;

proxyServer.BeforeRequest -= OnRequest;
proxyServer.BeforeResponse -= OnResponse;
proxyServer.BeforeRequest -= onRequest;
proxyServer.BeforeResponse -= onResponse;
proxyServer.ServerCertificateValidationCallback -= OnCertificateValidation;
proxyServer.ClientCertificateSelectionCallback -= OnCertificateSelection;

Expand All @@ -116,10 +116,10 @@ public void Stop()
//proxyServer.CertificateManager.RemoveTrustedRootCertificates();
}

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

if (hostname.Contains("dropbox.com"))
{
Expand All @@ -130,16 +130,16 @@ private async Task OnBeforeTunnelConnectRequest(object sender, TunnelConnectSess
}
}

private Task OnBeforeTunnelConnectResponse(object sender, TunnelConnectSessionEventArgs e)
private Task onBeforeTunnelConnectResponse(object sender, TunnelConnectSessionEventArgs e)
{
return Task.FromResult(false);
}

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

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

// Modify response
private async Task MultipartRequestPartSent(object sender, MultipartRequestPartSentEventArgs e)
private async Task multipartRequestPartSent(object sender, MultipartRequestPartSentEventArgs e)
{
var session = (SessionEventArgs)sender;
await WriteToConsole("Multipart form data headers:");
await writeToConsole("Multipart form data headers:");
foreach (var header in e.Headers)
{
await WriteToConsole(header.ToString());
await writeToConsole(header.ToString());
}
}

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

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

Expand Down Expand Up @@ -261,7 +261,7 @@ public Task OnCertificateSelection(object sender, CertificateSelectionEventArgs
return Task.FromResult(0);
}

private async Task WriteToConsole(string message, bool useRedColor = false)
private async Task writeToConsole(string message, bool useRedColor = false)
{
await @lock.WaitAsync();

Expand Down
18 changes: 9 additions & 9 deletions examples/Titanium.Web.Proxy.Examples.Wpf/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public SessionListItem SelectedSession
if (value != selectedSession)
{
selectedSession = value;
SelectedSessionChanged();
selectedSessionChanged();
}
}
}
Expand All @@ -131,7 +131,7 @@ private async Task ProxyServer_BeforeTunnelConnectRequest(object sender, TunnelC
e.DecryptSsl = false;
}

await Dispatcher.InvokeAsync(() => { AddSession(e); });
await Dispatcher.InvokeAsync(() => { addSession(e); });
}

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

if (e.HttpClient.Request.HasBody)
{
Expand Down Expand Up @@ -191,15 +191,15 @@ await Dispatcher.InvokeAsync(() =>
});
}

private SessionListItem AddSession(SessionEventArgsBase e)
private SessionListItem addSession(SessionEventArgsBase e)
{
var item = CreateSessionListItem(e);
var item = createSessionListItem(e);
Sessions.Add(item);
sessionDictionary.Add(e.HttpClient, item);
return item;
}

private SessionListItem CreateSessionListItem(SessionEventArgsBase e)
private SessionListItem createSessionListItem(SessionEventArgsBase e)
{
lastSessionNumber++;
bool isTunnelConnect = e is TunnelConnectSessionEventArgs;
Expand All @@ -214,7 +214,7 @@ private SessionListItem CreateSessionListItem(SessionEventArgsBase e)
{
e.DataReceived += (sender, args) =>
{
var session = (SessionEventArgs)sender;
var session = (SessionEventArgsBase)sender;
if (sessionDictionary.TryGetValue(session.HttpClient, out var li))
{
li.ReceivedDataCount += args.Count;
Expand All @@ -223,7 +223,7 @@ private SessionListItem CreateSessionListItem(SessionEventArgsBase e)

e.DataSent += (sender, args) =>
{
var session = (SessionEventArgs)sender;
var session = (SessionEventArgsBase)sender;
if (sessionDictionary.TryGetValue(session.HttpClient, out var li))
{
li.SentDataCount += args.Count;
Expand All @@ -248,7 +248,7 @@ private void ListViewSessions_OnKeyDown(object sender, KeyEventArgs e)
}
}

private void SelectedSessionChanged()
private void selectedSessionChanged()
{
if (SelectedSession == null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public sealed class NotNullAttribute : Attribute
}

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

/// <summary>
/// Can be appplied to symbols of types derived from IEnumerable as well as to symbols of Task
/// Can be applied to symbols of types derived from IEnumerable as well as to symbols of Task
/// and Lazy classes to indicate that the value of a collection item, of the Task.Result property
/// or of the Lazy.Value property can be null.
/// </summary>
Expand Down Expand Up @@ -251,7 +251,7 @@ public NotifyPropertyChangedInvocatorAttribute([NotNull] string parameterName)
/// </list>
/// If method has single input parameter, it's name could be omitted.<br />
/// Using <c>halt</c> (or <c>void</c>/<c>nothing</c>, which is the same) for method output
/// means that the methos doesn't return normally (throws or terminates the process).<br />
/// means that the method doesn't return normally (throws or terminates the process).<br />
/// Value <c>canbenull</c> is only applicable for output parameters.<br />
/// You can use multiple <c>[ContractAnnotation]</c> for each FDT row, or use single attribute
/// with rows separated by semicolon. There is no notion of order rows, all rows are checked
Expand Down
3 changes: 3 additions & 0 deletions src/Titanium.Web.Proxy.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,19 @@
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=MTA/@EntryIndexedValue">MTA</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=OID/@EntryIndexedValue">OID</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=OIDS/@EntryIndexedValue">OIDS</s:String>
<s:Boolean x:Key="/Default/CodeStyle/Naming/CSharpNaming/ApplyAutoDetectedRules/@EntryValue">False</s:Boolean>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateConstants/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticReadonly/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PublicFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<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>
<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>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpAttributeForSingleLineMethodUpgrade/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpKeepExistingMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpRenamePlacementToArrangementMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpUseContinuousIndentInsideBracesMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EAddAccessorOwnerDeclarationBracesMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002ECSharpPlaceAttributeOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class CertificateSelectionEventArgs : EventArgs
public X509Certificate RemoteCertificate { get; internal set; }

/// <summary>
/// Acceptable issuers as listed by remoted server.
/// Acceptable issuers as listed by remote server.
/// </summary>
public string[] AcceptableIssuers { get; internal set; }

Expand Down
16 changes: 8 additions & 8 deletions src/Titanium.Web.Proxy/EventArguments/SessionEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ internal void OnMultipartRequestPartSent(string boundary, HeaderCollection heade
}
catch (Exception ex)
{
exceptionFunc(new Exception("Exception thrown in user event", ex));
ExceptionFunc(new Exception("Exception thrown in user event", ex));
}
}

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

if (isRequest)
{
Expand Down Expand Up @@ -186,7 +186,7 @@ internal async Task SyphonOutBodyAsync(bool isRequest, CancellationToken cancell

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

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

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

Stream s = limitedStream = new LimitedStream(stream, bufferPool, isChunked, contentLength);
Stream s = limitedStream = new LimitedStream(stream, BufferPool, isChunked, contentLength);

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

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

var buffer = bufferPool.GetBuffer(bufferSize);
var buffer = BufferPool.GetBuffer(BufferSize);
try
{
int boundaryLength = boundary.Length + 4;
Expand Down Expand Up @@ -340,7 +340,7 @@ private async Task<long> readUntilBoundaryAsync(ICustomStreamReader reader, long
}
finally
{
bufferPool.ReturnBuffer(buffer);
BufferPool.ReturnBuffer(buffer);
}
}

Expand Down
Loading