Commit 0ea90e0c authored by justcoding121's avatar justcoding121 Committed by justcoding121

user lazy<bool> for runtime check

parent 12e910fe
......@@ -7,15 +7,13 @@ namespace Titanium.Web.Proxy.Helpers
/// </summary>
internal class RunTime
{
private static Lazy<bool> isMonoRuntime
= new Lazy<bool>(()=> Type.GetType("Mono.Runtime") != null);
/// <summary>
/// Checks if current run time is Mono
/// </summary>
/// <returns></returns>
internal static bool IsRunningOnMono()
{
return isMonoRuntime.Value;
}
internal static Lazy<bool> isRunningOnMono
= new Lazy<bool>(()=> Type.GetType("Mono.Runtime") != null);
internal static bool IsRunningOnMono => isRunningOnMono.Value;
}
}
......@@ -39,7 +39,7 @@ namespace Titanium.Web.Proxy.Network
set
{
//For Mono only Bouncy Castle is supported
if (RunTime.IsRunningOnMono())
if (RunTime.IsRunningOnMono)
{
value = CertificateEngine.BouncyCastle;
}
......@@ -226,7 +226,7 @@ namespace Titanium.Web.Proxy.Network
/// <returns></returns>
public bool TrustRootCertificateAsAdministrator()
{
if (RunTime.IsRunningOnMono())
if (RunTime.IsRunningOnMono)
{
return false;
}
......
......@@ -348,7 +348,7 @@ namespace Titanium.Web.Proxy
/// <param name="endPoint"></param>
public void SetAsSystemHttpProxy(ExplicitProxyEndPoint endPoint)
{
if (RunTime.IsRunningOnMono())
if (RunTime.IsRunningOnMono)
{
throw new Exception("Mono Runtime do not support system proxy settings.");
}
......@@ -375,7 +375,7 @@ namespace Titanium.Web.Proxy
/// <param name="endPoint"></param>
public void SetAsSystemHttpsProxy(ExplicitProxyEndPoint endPoint)
{
if (RunTime.IsRunningOnMono())
if (RunTime.IsRunningOnMono)
{
throw new Exception("Mono Runtime do not support system proxy settings.");
}
......@@ -416,7 +416,7 @@ namespace Titanium.Web.Proxy
/// </summary>
public void DisableSystemHttpProxy()
{
if (RunTime.IsRunningOnMono())
if (RunTime.IsRunningOnMono)
{
throw new Exception("Mono Runtime do not support system proxy settings.");
}
......@@ -429,7 +429,7 @@ namespace Titanium.Web.Proxy
/// </summary>
public void DisableSystemHttpsProxy()
{
if (RunTime.IsRunningOnMono())
if (RunTime.IsRunningOnMono)
{
throw new Exception("Mono Runtime do not support system proxy settings.");
}
......@@ -442,7 +442,7 @@ namespace Titanium.Web.Proxy
/// </summary>
public void DisableAllSystemProxies()
{
if (RunTime.IsRunningOnMono())
if (RunTime.IsRunningOnMono)
{
throw new Exception("Mono Runtime do not support system proxy settings.");
}
......@@ -474,7 +474,7 @@ namespace Titanium.Web.Proxy
CertificateManager.ClearIdleCertificates(CertificateCacheTimeOutMinutes);
if (!RunTime.IsRunningOnMono())
if (!RunTime.IsRunningOnMono)
{
WinAuthEndPoint.ClearIdleStates(2);
}
......
......@@ -326,7 +326,7 @@ namespace Titanium.Web.Proxy
//we need a cache of request body
//so that we can send it after authentication in WinAuthHandler.cs
if (EnableWinAuth
&& !RunTime.IsRunningOnMono()
&& !RunTime.IsRunningOnMono
&& args.WebSession.Request.HasBody)
{
await args.GetRequestBody();
......@@ -471,8 +471,7 @@ namespace Titanium.Web.Proxy
if (!args.WebSession.Request.ExpectationFailed)
{
//If its a post/put/patch request, then read the client html body and send it to server
var method = args.WebSession.Request.Method.ToUpper();
if (method == "POST" || method == "PUT" || method == "PATCH")
if (args.WebSession.Request.HasBody)
{
await SendClientRequestBody(args);
}
......
......@@ -38,7 +38,7 @@ namespace Titanium.Web.Proxy
//check for windows authentication
if(EnableWinAuth
&& !RunTime.IsRunningOnMono()
&& !RunTime.IsRunningOnMono
&& args.WebSession.Response.ResponseStatusCode == "401")
{
var disposed = await Handle401UnAuthorized(args);
......
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