Commit 158b6143 authored by justcoding121's avatar justcoding121 Committed by justcoding121

Fix event handler

parent 487b8912
Titanium.ProxyTest/Capture.PNG

27.1 KB | W: | H:

Titanium.ProxyTest/Capture.PNG

23.8 KB | W: | H:

Titanium.ProxyTest/Capture.PNG
Titanium.ProxyTest/Capture.PNG
Titanium.ProxyTest/Capture.PNG
Titanium.ProxyTest/Capture.PNG
  • 2-up
  • Swipe
  • Onion skin
...@@ -19,17 +19,19 @@ namespace Titanium.HTTPProxyServer.Test ...@@ -19,17 +19,19 @@ namespace Titanium.HTTPProxyServer.Test
//Start proxy controller //Start proxy controller
var controller = new ProxyTestController(); var controller = new ProxyTestController();
controller.StartProxy();
controller.Visited += PageVisited; controller.Visited += PageVisited;
Console.WriteLine("Do you want to monitor HTTPS? (Y/N)"); controller.StartProxy();
Console.Write("Do you want to monitor HTTPS? (Y/N):");
if(Console.ReadLine().Trim().ToLower()=="y" ) if(Console.ReadLine().Trim().ToLower()=="y" )
{ {
InstallCertificate(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)); InstallCertificate(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location));
SystemProxyUtility.EnableProxyHTTPS("localhost", controller.ListeningPort); SystemProxyUtility.EnableProxyHTTPS("localhost", controller.ListeningPort);
} }
Console.WriteLine("Hit any key to exit"); Console.WriteLine("Hit any key to exit..");
Console.WriteLine();
Console.Read(); Console.Read();
//Reset System Proxy on exit //Reset System Proxy on exit
...@@ -54,7 +56,7 @@ namespace Titanium.HTTPProxyServer.Test ...@@ -54,7 +56,7 @@ namespace Titanium.HTTPProxyServer.Test
} }
private static void PageVisited(VisitedEventArgs e) private static void PageVisited(VisitedEventArgs e)
{ {
Console.WriteLine(string.Concat("Visited:", e.URL)); Console.WriteLine(string.Concat("Visited: ", e.URL));
} }
static bool ConsoleEventCallback(int eventType) static bool ConsoleEventCallback(int eventType)
{ {
......
...@@ -17,34 +17,37 @@ namespace Titanium.HTTPProxyServer.Test ...@@ -17,34 +17,37 @@ namespace Titanium.HTTPProxyServer.Test
{ {
private List<string> _URLList = new List<string>(); private List<string> _URLList = new List<string>();
private string _lastURL = string.Empty; private string _lastURL = string.Empty;
private ProxyServer _server;
public int ListeningPort { get; set; } public int ListeningPort { get; set; }
public void StartProxy() public void StartProxy()
{ {
_server = new ProxyServer(); if(Visited!=null)
_server.BeforeRequest += OnRequest; {
_server.BeforeResponse += OnResponse; ProxyServer.BeforeRequest += OnRequest;
_server.Start(); ProxyServer.BeforeResponse += OnResponse;
}
ProxyServer.Start();
SystemProxyUtility.EnableProxyHTTP("localhost", _server.ListeningPort); SystemProxyUtility.EnableProxyHTTP("localhost", ProxyServer.ListeningPort);
FireFoxUtility.AddFirefox(); FireFoxUtility.AddFirefox();
ListeningPort = _server.ListeningPort; ListeningPort = ProxyServer.ListeningPort;
Console.WriteLine(String.Format("Proxy listening on local machine port: {0} ", _server.ListeningPort)); Console.WriteLine(String.Format("Proxy listening on local machine port: {0} ", ProxyServer.ListeningPort));
} }
public void Stop() public void Stop()
{ {
if (Visited!=null)
_server.BeforeRequest -= OnRequest; {
_server.BeforeResponse -= OnResponse; ProxyServer.BeforeRequest -= OnRequest;
ProxyServer.BeforeResponse -= OnResponse;
_server.Stop(); }
ProxyServer.Stop();
} }
......
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