Commit 74ed1c2e authored by titanium007's avatar titanium007

Comment out sample code

parent 11563d36
......@@ -26,18 +26,6 @@ After installing nuget package mark following files to be copied to app director
* makecert.exe
* Titanium_Proxy_Test_Root.cer
Or install manually:
Add reference to
* Titanium.Web.Proxy.dll
These files also should be in your application directory
* Ionic.Zip.dll
* makecert.exe
* Titanium_Proxy_Test_Root.cer
Setup HTTP proxy:
......
......@@ -60,22 +60,22 @@ namespace Titanium.Web.Proxy.Test
Console.WriteLine(e.RequestURL);
if (e.RequestURL.Contains("somewebsite.com"))
if ((e.ProxyRequest.Method.ToUpper() == "POST" || e.ProxyRequest.Method.ToUpper() == "PUT") && e.ProxyRequest.ContentLength > 0)
{
//if (e.RequestURL.Contains("somewebsite.com"))
// if ((e.ProxyRequest.Method.ToUpper() == "POST" || e.ProxyRequest.Method.ToUpper() == "PUT") && e.ProxyRequest.ContentLength > 0)
// {
var m = e.GetRequestBody().Replace("a", "b");
e.SetRequestBody(m);
// var m = e.GetRequestBody().Replace("a", "b");
// e.SetRequestBody(m);
}
// }
//To cancel a request with a custom HTML content
//Filter URL
////To cancel a request with a custom HTML content
////Filter URL
if (e.RequestURL.Contains("somewebsite.com"))
{
e.Ok("<!DOCTYPE html><html><body><h1>Blocked</h1><p>Website blocked.</p></body></html>");
}
//if (e.RequestURL.Contains("somewebsite.com"))
//{
// e.Ok("<!DOCTYPE html><html><body><h1>Blocked</h1><p>Website blocked.</p></body></html>");
//}
}
......@@ -85,21 +85,21 @@ namespace Titanium.Web.Proxy.Test
{
//To modify a response
if (e.ServerResponse.StatusCode == HttpStatusCode.OK)
{
if (e.ServerResponse.ContentType.Trim().ToLower().Contains("text/html"))
{
//Get response body
string responseBody = e.GetResponseBody();
//if (e.ServerResponse.StatusCode == HttpStatusCode.OK)
//{
// if (e.ServerResponse.ContentType.Trim().ToLower().Contains("text/html"))
// {
// //Get response body
// string responseBody = e.GetResponseBody();
//Modify e.ServerResponse
Regex rex = new Regex("</body>", RegexOptions.RightToLeft | RegexOptions.IgnoreCase | RegexOptions.Multiline);
string modified = rex.Replace(responseBody, "<script type =\"text/javascript\">alert('Response was modified by this script!');</script></body>", 1);
// //Modify e.ServerResponse
// Regex rex = new Regex("</body>", RegexOptions.RightToLeft | RegexOptions.IgnoreCase | RegexOptions.Multiline);
// string modified = rex.Replace(responseBody, "<script type =\"text/javascript\">alert('Response was modified by this script!');</script></body>", 1);
//Set modifed response Html Body
e.SetResponseBody(modified);
}
}
// //Set modifed response Html Body
// e.SetResponseBody(modified);
// }
//}
}
......
......@@ -38,7 +38,7 @@ namespace Titanium.Web.Proxy
{
string httpsDecoratedHostName = null, tmpLine = null;
List<string> requestLines = new List<string>();
while (!String.IsNullOrEmpty(tmpLine = clientStreamReader.ReadLine()))
{
requestLines.Add(tmpLine);
......@@ -75,12 +75,12 @@ namespace Titanium.Web.Proxy
//instead = we are going to perform a man in the middle "attack"
//the user's browser should warn them of the certification errors,
//to avoid that we need to install our root certficate in users machine as Certificate Authority.
remoteUri = "https://" + splitBuffer[1];
HttpsHostName = splitBuffer[1].Split(':')[0];
int.TryParse(splitBuffer[1].Split(':')[1], out httpsPort);
requestLines.Clear();
clientStreamWriter.WriteLine(RequestVersion + " 200 Connection established");
......@@ -110,7 +110,7 @@ namespace Titanium.Web.Proxy
//Pinned certificate clients cannot be proxied
//For example dropbox clients use certificate pinning
//So just relay the request
if (!ExcludedHttpsHostNameRegex.Any(x=> Regex.IsMatch(HttpsHostName,x)))
if (!ExcludedHttpsHostNameRegex.Any(x => Regex.IsMatch(HttpsHostName, x)))
{
try
{
......@@ -125,7 +125,7 @@ namespace Titanium.Web.Proxy
}
catch
{
{
if (sslStream != null)
sslStream.Dispose();
......@@ -319,7 +319,7 @@ namespace Titanium.Web.Proxy
Dispose(client, clientStream, clientStreamReader, clientStreamWriter, args);
}
}
private static void Dispose(TcpClient client, Stream clientStream, CustomBinaryReader clientStreamReader, StreamWriter clientStreamWriter, SessionEventArgs args)
{
......@@ -372,7 +372,7 @@ namespace Titanium.Web.Proxy
webRequest.ContentLength = contentLen;
break;
case "content-type":
webRequest.ContentType = header[1];
webRequest.ContentType = header[1];
break;
case "expect":
if (header[1].ToLower() == "100-continue")
......@@ -471,7 +471,7 @@ namespace Titanium.Web.Proxy
}
postStream.Close();
}
catch
{
......
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