Commit 28f78650 authored by justcoding121's avatar justcoding121

avoid slowness in demo (uncomment)

parent 5d22fe00
...@@ -165,31 +165,31 @@ namespace Titanium.Web.Proxy.Examples.Basic ...@@ -165,31 +165,31 @@ namespace Titanium.Web.Proxy.Examples.Basic
// e.MultipartRequestPartSent += MultipartRequestPartSent; // e.MultipartRequestPartSent += MultipartRequestPartSent;
//} //}
if (e.WebSession.Request.HasBody) //if (e.WebSession.Request.HasBody)
{ //{
//Get/Set request body bytes // //Get/Set request body bytes
var bodyBytes = await e.GetRequestBody(); // var bodyBytes = await e.GetRequestBody();
await e.SetRequestBody(bodyBytes); // await e.SetRequestBody(bodyBytes);
//Get/Set request body as string // //Get/Set request body as string
string bodyString = await e.GetRequestBodyAsString(); // string bodyString = await e.GetRequestBodyAsString();
await e.SetRequestBodyString(bodyString); // await e.SetRequestBodyString(bodyString);
//requestBodyHistory[e.Id] = bodyString; // //requestBodyHistory[e.Id] = bodyString;
} //}
//To cancel a request with a custom HTML content //To cancel a request with a custom HTML content
//Filter URL //Filter URL
if (e.WebSession.Request.RequestUri.AbsoluteUri.Contains("yahoo.com")) //if (e.WebSession.Request.RequestUri.AbsoluteUri.Contains("yahoo.com"))
{ //{
e.Ok("<!DOCTYPE html>" + // e.Ok("<!DOCTYPE html>" +
"<html><body><h1>" + // "<html><body><h1>" +
"Website Blocked" + // "Website Blocked" +
"</h1>" + // "</h1>" +
"<p>Blocked by titanium web proxy.</p>" + // "<p>Blocked by titanium web proxy.</p>" +
"</body>" + // "</body>" +
"</html>"); // "</html>");
} //}
////Redirect example ////Redirect example
//if (e.WebSession.Request.RequestUri.AbsoluteUri.Contains("wikipedia.org")) //if (e.WebSession.Request.RequestUri.AbsoluteUri.Contains("wikipedia.org"))
...@@ -219,27 +219,27 @@ namespace Titanium.Web.Proxy.Examples.Basic ...@@ -219,27 +219,27 @@ namespace Titanium.Web.Proxy.Examples.Basic
// var requestBody = requestBodyHistory[e.Id]; // var requestBody = requestBodyHistory[e.Id];
//} //}
//read response headers ////read response headers
responseHeaderHistory[e.Id] = e.WebSession.Response.Headers; //responseHeaderHistory[e.Id] = e.WebSession.Response.Headers;
// print out process id of current session //// print out process id of current session
//Console.WriteLine($"PID: {e.WebSession.ProcessId.Value}"); ////Console.WriteLine($"PID: {e.WebSession.ProcessId.Value}");
//if (!e.ProxySession.Request.Host.Equals("medeczane.sgk.gov.tr")) return; ////if (!e.ProxySession.Request.Host.Equals("medeczane.sgk.gov.tr")) return;
if (e.WebSession.Request.Method == "GET" || e.WebSession.Request.Method == "POST") //if (e.WebSession.Request.Method == "GET" || e.WebSession.Request.Method == "POST")
{ //{
if (e.WebSession.Response.StatusCode == (int)HttpStatusCode.OK) // if (e.WebSession.Response.StatusCode == (int)HttpStatusCode.OK)
{ // {
if (e.WebSession.Response.ContentType != null && e.WebSession.Response.ContentType.Trim().ToLower().Contains("text/html")) // if (e.WebSession.Response.ContentType != null && e.WebSession.Response.ContentType.Trim().ToLower().Contains("text/html"))
{ // {
var bodyBytes = await e.GetResponseBody(); // var bodyBytes = await e.GetResponseBody();
await e.SetResponseBody(bodyBytes); // await e.SetResponseBody(bodyBytes);
string body = await e.GetResponseBodyAsString(); // string body = await e.GetResponseBodyAsString();
await e.SetResponseBodyString(body); // await e.SetResponseBodyString(body);
} // }
} // }
} //}
} }
/// <summary> /// <summary>
......
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