Commit 77d9258f authored by Honfika's avatar Honfika

inconsistent naming fixes

parent 6996456c
......@@ -32,11 +32,11 @@ namespace Titanium.Web.Proxy.Examples.Basic
{
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;
......@@ -52,8 +52,8 @@ namespace Titanium.Web.Proxy.Examples.Basic
public void StartProxy()
{
proxyServer.BeforeRequest += OnRequest;
proxyServer.BeforeResponse += OnResponse;
proxyServer.BeforeRequest += onRequest;
proxyServer.BeforeResponse += onResponse;
proxyServer.ServerCertificateValidationCallback += OnCertificateValidation;
proxyServer.ClientCertificateSelectionCallback += OnCertificateSelection;
......@@ -63,7 +63,7 @@ namespace Titanium.Web.Proxy.Examples.Basic
explicitEndPoint = new ExplicitProxyEndPoint(IPAddress.Any, 8000);
// Fired when a CONNECT request is received
explicitEndPoint.BeforeTunnelConnectRequest += OnBeforeTunnelConnectRequest;
explicitEndPoint.BeforeTunnelConnectRequest += onBeforeTunnelConnectRequest;
explicitEndPoint.BeforeTunnelConnectResponse += OnBeforeTunnelConnectResponse;
// An explicit endpoint is where the client knows about the existence of a proxy
......@@ -102,11 +102,11 @@ namespace Titanium.Web.Proxy.Examples.Basic
public void Stop()
{
explicitEndPoint.BeforeTunnelConnectRequest -= OnBeforeTunnelConnectRequest;
explicitEndPoint.BeforeTunnelConnectRequest -= onBeforeTunnelConnectRequest;
explicitEndPoint.BeforeTunnelConnectResponse -= OnBeforeTunnelConnectResponse;
proxyServer.BeforeRequest -= OnRequest;
proxyServer.BeforeResponse -= OnResponse;
proxyServer.BeforeRequest -= onRequest;
proxyServer.BeforeResponse -= onResponse;
proxyServer.ServerCertificateValidationCallback -= OnCertificateValidation;
proxyServer.ClientCertificateSelectionCallback -= OnCertificateSelection;
......@@ -116,10 +116,10 @@ namespace Titanium.Web.Proxy.Examples.Basic
//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"))
{
......@@ -136,10 +136,10 @@ namespace Titanium.Web.Proxy.Examples.Basic
}
// 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
......@@ -177,19 +177,19 @@ namespace Titanium.Web.Proxy.Examples.Basic
}
// 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);
......@@ -261,7 +261,7 @@ namespace Titanium.Web.Proxy.Examples.Basic
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();
......
......@@ -106,7 +106,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
if (value != selectedSession)
{
selectedSession = value;
SelectedSessionChanged();
selectedSessionChanged();
}
}
}
......@@ -131,7 +131,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
e.DecryptSsl = false;
}
await Dispatcher.InvokeAsync(() => { AddSession(e); });
await Dispatcher.InvokeAsync(() => { addSession(e); });
}
private async Task ProxyServer_BeforeTunnelConnectResponse(object sender, TunnelConnectSessionEventArgs e)
......@@ -148,7 +148,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
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)
{
......@@ -191,15 +191,15 @@ namespace Titanium.Web.Proxy.Examples.Wpf
});
}
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;
......@@ -248,7 +248,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
}
}
private void SelectedSessionChanged()
private void selectedSessionChanged()
{
if (SelectedSession == null)
{
......
......@@ -19,10 +19,12 @@
<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>
......
......@@ -117,7 +117,7 @@ namespace Titanium.Web.Proxy.EventArguments
}
catch (Exception ex)
{
exceptionFunc(new Exception("Exception thrown in user event", ex));
ExceptionFunc(new Exception("Exception thrown in user event", ex));
}
}
......@@ -154,7 +154,7 @@ namespace Titanium.Web.Proxy.EventArguments
{
using (var bodyStream = new MemoryStream())
{
var writer = new HttpWriter(bodyStream, bufferPool, bufferSize);
var writer = new HttpWriter(bodyStream, BufferPool, BufferSize);
if (isRequest)
{
......@@ -186,7 +186,7 @@ namespace Titanium.Web.Proxy.EventArguments
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);
}
}
......@@ -207,7 +207,7 @@ namespace Titanium.Web.Proxy.EventArguments
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)
{
......@@ -259,7 +259,7 @@ namespace Titanium.Web.Proxy.EventArguments
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)
{
......@@ -268,7 +268,7 @@ namespace Titanium.Web.Proxy.EventArguments
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);
}
......@@ -290,7 +290,7 @@ namespace Titanium.Web.Proxy.EventArguments
{
int bufferDataLength = 0;
var buffer = bufferPool.GetBuffer(bufferSize);
var buffer = BufferPool.GetBuffer(BufferSize);
try
{
int boundaryLength = boundary.Length + 4;
......@@ -340,7 +340,7 @@ namespace Titanium.Web.Proxy.EventArguments
}
finally
{
bufferPool.ReturnBuffer(buffer);
BufferPool.ReturnBuffer(buffer);
}
}
......
......@@ -24,9 +24,9 @@ namespace Titanium.Web.Proxy.EventArguments
internal TcpServerConnection ServerConnection => HttpClient.Connection;
internal TcpClientConnection ClientConnection => ProxyClient.Connection;
protected readonly int bufferSize;
protected readonly IBufferPool bufferPool;
protected readonly ExceptionHandler exceptionFunc;
protected readonly int BufferSize;
protected readonly IBufferPool BufferPool;
protected readonly ExceptionHandler ExceptionFunc;
/// <summary>
/// Relative milliseconds for various events.
......@@ -39,9 +39,9 @@ namespace Titanium.Web.Proxy.EventArguments
private SessionEventArgsBase(ProxyServer server, ProxyEndPoint endPoint,
CancellationTokenSource cancellationTokenSource)
{
bufferSize = server.BufferSize;
bufferPool = server.BufferPool;
exceptionFunc = server.ExceptionFunc;
BufferSize = server.BufferSize;
BufferPool = server.BufferPool;
ExceptionFunc = server.ExceptionFunc;
TimeLine["Session Created"] = DateTime.Now;
}
......@@ -161,7 +161,7 @@ namespace Titanium.Web.Proxy.EventArguments
}
catch (Exception ex)
{
exceptionFunc(new Exception("Exception thrown in user event", ex));
ExceptionFunc(new Exception("Exception thrown in user event", ex));
}
}
......@@ -173,7 +173,7 @@ namespace Titanium.Web.Proxy.EventArguments
}
catch (Exception ex)
{
exceptionFunc(new Exception("Exception thrown in user event", ex));
ExceptionFunc(new Exception("Exception thrown in user event", ex));
}
}
......
......@@ -70,7 +70,7 @@ namespace Titanium.Web.Proxy.Helpers
internal static bool IsRunningAsUwp()
{
if (IsWindows7OrLower)
if (isWindows7OrLower)
{
return false;
}
......@@ -87,7 +87,7 @@ namespace Titanium.Web.Proxy.Helpers
}
}
private static bool IsWindows7OrLower
private static bool isWindows7OrLower
{
get
{
......
......@@ -80,7 +80,7 @@ namespace Titanium.Web.Proxy.Helpers
/// <param name="protocolType"></param>
internal void SetProxy(string hostname, int port, ProxyProtocolType protocolType)
{
using (var reg = OpenInternetSettingsKey())
using (var reg = openInternetSettingsKey())
{
if (reg == null)
{
......@@ -127,7 +127,7 @@ namespace Titanium.Web.Proxy.Helpers
/// </summary>
internal void RemoveProxy(ProxyProtocolType protocolType, bool saveOriginalConfig = true)
{
using (var reg = OpenInternetSettingsKey())
using (var reg = openInternetSettingsKey())
{
if (reg == null)
{
......@@ -168,7 +168,7 @@ namespace Titanium.Web.Proxy.Helpers
/// </summary>
internal void DisableAllProxy()
{
using (var reg = OpenInternetSettingsKey())
using (var reg = openInternetSettingsKey())
{
if (reg == null)
{
......@@ -186,7 +186,7 @@ namespace Titanium.Web.Proxy.Helpers
internal void SetAutoProxyUrl(string url)
{
using (var reg = OpenInternetSettingsKey())
using (var reg = openInternetSettingsKey())
{
if (reg == null)
{
......@@ -201,7 +201,7 @@ namespace Titanium.Web.Proxy.Helpers
internal void SetProxyOverride(string proxyOverride)
{
using (var reg = OpenInternetSettingsKey())
using (var reg = openInternetSettingsKey())
{
if (reg == null)
{
......@@ -286,7 +286,7 @@ namespace Titanium.Web.Proxy.Helpers
internal ProxyInfo GetProxyInfoFromRegistry()
{
using (var reg = OpenInternetSettingsKey())
using (var reg = openInternetSettingsKey())
{
if (reg == null)
{
......@@ -347,7 +347,7 @@ namespace Titanium.Web.Proxy.Helpers
/// <summary>
/// Opens the registry key with the internet settings
/// </summary>
private static RegistryKey OpenInternetSettingsKey()
private static RegistryKey openInternetSettingsKey()
{
return Registry.CurrentUser.OpenSubKey(regKeyInternetSettings, true);
}
......
......@@ -38,11 +38,11 @@ namespace Titanium.Web.Proxy.Network.Tcp
internal TcpConnectionFactory(ProxyServer server)
{
this.server = server;
this.Server = server;
Task.Run(async () => await clearOutdatedConnections());
}
internal ProxyServer server { get; set; }
internal ProxyServer Server { get; set; }
internal string GetConnectionCacheKey(string remoteHostName, int remotePort,
bool isHttps, List<SslApplicationProtocol> applicationProtocols,
......@@ -232,7 +232,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
CancellationToken cancellationToken)
{
//deny connection to proxy end points to avoid infinite connection loop.
if (server.ProxyEndPoints.Any(x => x.Port == remotePort)
if (Server.ProxyEndPoints.Any(x => x.Port == remotePort)
&& NetworkHelper.IsLocalIpAddress(remoteHostName))
{
throw new Exception($"A client is making HTTP request to one of the listening ports of this proxy {remoteHostName}:{remotePort}");
......@@ -240,7 +240,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
if (externalProxy != null)
{
if (server.ProxyEndPoints.Any(x => x.Port == externalProxy.Port)
if (Server.ProxyEndPoints.Any(x => x.Port == externalProxy.Port)
&& NetworkHelper.IsLocalIpAddress(externalProxy.HostName))
{
throw new Exception($"A client is making HTTP request via external proxy to one of the listening ports of this proxy {remoteHostName}:{remotePort}");
......@@ -416,7 +416,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
return;
}
if (close || connection.IsWinAuthenticated || !server.EnableConnectionPool || connection.Stream.IsClosed)
if (close || connection.IsWinAuthenticated || !Server.EnableConnectionPool || connection.Stream.IsClosed)
{
disposalBag.Add(connection);
return;
......@@ -432,7 +432,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
{
if (cache.TryGetValue(connection.CacheKey, out var existingConnections))
{
while (existingConnections.Count >= server.MaxCachedConnections)
while (existingConnections.Count >= Server.MaxCachedConnections)
{
if (existingConnections.TryDequeue(out var staleConnection))
{
......@@ -489,8 +489,8 @@ namespace Titanium.Web.Proxy.Network.Tcp
{
if (queue.TryDequeue(out var connection))
{
var cutOff = DateTime.Now.AddSeconds(-1 * server.ConnectionTimeOutSeconds);
if (!server.EnableConnectionPool
var cutOff = DateTime.Now.AddSeconds(-1 * Server.ConnectionTimeOutSeconds);
if (!Server.EnableConnectionPool
|| connection.LastAccess < cutOff)
{
disposalBag.Add(connection);
......@@ -530,7 +530,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
}
catch (Exception e)
{
server.ExceptionFunc(new Exception("An error occurred when disposing server connections.", e));
Server.ExceptionFunc(new Exception("An error occurred when disposing server connections.", e));
}
finally
{
......
//
//
// Mono.Security.BitConverterLE.cs
// Like System.BitConverter but always little endian
//
......
......@@ -43,7 +43,7 @@ namespace Titanium.Web.Proxy.IntegrationTests.Helpers
if (!requireBody)
return request as Request;
if (ParseBody(reader, ref request))
if (parseBody(reader, ref request))
return request as Request;
}
catch { }
......@@ -84,7 +84,7 @@ namespace Titanium.Web.Proxy.IntegrationTests.Helpers
if (line?.Length != 0)
return null;
if (ParseBody(reader, ref response))
if (parseBody(reader, ref response))
return response as Response;
}
catch { }
......@@ -92,7 +92,7 @@ namespace Titanium.Web.Proxy.IntegrationTests.Helpers
return null;
}
private static bool ParseBody(StringReader reader, ref RequestResponseBase obj)
private static bool parseBody(StringReader reader, ref RequestResponseBase obj)
{
obj.OriginalContentLength = obj.ContentLength;
if (obj.ContentLength <= 0)
......
......@@ -11,22 +11,22 @@ namespace Titanium.Web.Proxy.UnitTests
public class SystemProxyTest
{
[TestMethod]
public void CompareProxyAdddressReturendByWebProxyAndWinHttpProxyResolver()
public void CompareProxyAddressReturnedByWebProxyAndWinHttpProxyResolver()
{
var proxyManager = new SystemProxyManager();
try
{
CompareUrls();
compareUrls();
proxyManager.SetProxy("127.0.0.1", 8000, ProxyProtocolType.Http);
CompareUrls();
compareUrls();
proxyManager.SetProxy("127.0.0.1", 8000, ProxyProtocolType.Https);
CompareUrls();
compareUrls();
proxyManager.SetProxy("127.0.0.1", 8000, ProxyProtocolType.AllHttp);
CompareUrls();
compareUrls();
// for this test you need to add a proxy.pac file to a local webserver
//function FindProxyForURL(url, host)
......@@ -43,25 +43,25 @@ namespace Titanium.Web.Proxy.UnitTests
//CompareUrls();
proxyManager.SetProxyOverride("<-loopback>");
CompareUrls();
compareUrls();
proxyManager.SetProxyOverride("<local>");
CompareUrls();
compareUrls();
proxyManager.SetProxyOverride("yahoo.com");
CompareUrls();
compareUrls();
proxyManager.SetProxyOverride("*.local");
CompareUrls();
compareUrls();
proxyManager.SetProxyOverride("http://*.local");
CompareUrls();
compareUrls();
proxyManager.SetProxyOverride("<-loopback>;*.local");
CompareUrls();
compareUrls();
proxyManager.SetProxyOverride("<-loopback>;*.local;<local>");
CompareUrls();
compareUrls();
}
finally
{
......@@ -69,7 +69,7 @@ namespace Titanium.Web.Proxy.UnitTests
}
}
private void CompareUrls()
private void compareUrls()
{
var webProxy = WebRequest.GetSystemWebProxy();
......
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