Skip to content

jimevans/FryProxy

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FryProxy

Extensible man in the middle HTTP proxy with SSL support. It was written because I need a way to monitor and possibly stub some browser request in selenium tests. It also available as NuGet Package

Examples:

Setup HTTP proxy:

  var httpProxyServer = new HttpProxyServer("localhost", new HttpProxy());
  httpProxyServer.Start().WaitOne();
  
  // do stuff
  
  httpProxyServer.stop();

Setup SSL proxy:

  var certificate = new X509Certificate2("path_to_sertificate", "password");
  var sslProxyServer = new HttpProxyServer("localhost", new SslProxy(certificate));
  sslProxyServer.start();
  
  // do ssl stuff
  
  sslProxyServer.stop();

Extension points

Request are processed in 5 stages:

  • receive request from client
  • connect to destination server
  • send request to server and receive response
  • send response back to client
  • complete processing and close connections

It is possible to add additional behavior to any stage with delegates:

  var httpProxy = new HttpProxy(){
    OnRequestReceived = context => {},
    OnServerConnected = context => {},
    OnResponseReceived = context => {},
    OnResponseSent = context => {},
    OnProcessingComplete = context => {}
  };

Context stores request information during processing single request. What you can possibly do with it ?

  • modify request and response headers
  • modify request and response body
  • respond by yourself on behalf of destination server
  • ...or something in between

Take a look at console app and tests for usage example.

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%