若是要开发的自定义插件有UI界面,则须要实现IFiddlerExtension 接口。你程序集中的实现了IFiddlerExtension接口的公有类(public class)将会在Fiddler启动时加载。缓存
public interface IFiddlerExtension { // Called when Fiddler User Interface is fully available void OnLoad(); // Called when Fiddler is shutting down void OnBeforeUnload(); }
IAutoTamper 接口继承了IFiddlerExtension接口,全部实现了IAutoTamper 接口的插件将会在每个http/https 请求或响应时被调用,因此能够用来劫持或修改http/https 请求响应数据。安全
注意:这个接口的方法是在后台被调用,非UI线程,若是想要更新UI,能够使用Invoke 或者 BeginInvoke 方法来更新UI。IAutoTamper 的全部方法可能会在OnLoad事件以前就执行。less
public interface IAutoTamper : IFiddlerExtension { // Called before the user can edit a request using the Fiddler Inspectors void AutoTamperRequestBefore(Session oSession); // Called after the user has had the chance to edit the request using the Fiddler Inspectors, but before the request is sent void AutoTamperRequestAfter(Session oSession); // Called before the user can edit a response using the Fiddler Inspectors, unless streaming. void AutoTamperResponseBefore(Session oSession); // Called after the user edited a response using the Fiddler Inspectors. Not called when streaming. void AutoTamperResponseAfter(Session oSession); // Called Fiddler returns a self-generated HTTP error (for instance DNS lookup failed, etc) void OnBeforeReturningError(Session oSession); }
全部实现了IAutoTamper2 接口(继承自IAutoTamper接口)的扩展将会在响应头(Response Headers)可用时被调用。ui
/// <summary> /// Interface for AutoTamper extensions that want to "peek" at response headers /// </summary> public interface IAutoTamper2 : IAutoTamper { /// <summary> /// Called when the response headers become available /// </summary> /// <param name="oSession">The Session object for which the response headers are available</param> void OnPeekAtResponseHeaders(Session oSession); }
全部实现了IAutoTamper3接口(继承自IAutoTamper2接口)的扩展将会在请求头(Request Headers)可用时被调用。spa
/// <summary> /// Interface for AutoTamper extensions that want to "peek" at request headers /// </summary> public interface IAutoTamper3 : IAutoTamper2 { /// <summary> /// Called when the request headers become available /// </summary> /// <param name="oSession">The Session object for which the request headers are available</param> void OnPeekAtRequestHeaders(Session oSession); }
IHandleExecAction接口
全部实现了IHandleExecAction
接口的扩展将在用户执行QuickExec命令时被调用。OnExecAction方法中返回 true 表示命令执行成功,不用再处理其余Action。插件
public interface IHandleExecAction { // return TRUE if handled. bool OnExecAction(string sCommand); }
例如:线程
public bool OnExecAction(string sCommand) { if (sCommand == "clearcache") { //检测到用户在quickexec中输入的命令是clearcache时,调用Fiddler的清缓存方法 FiddlerApplication.UI.actClearWinINETCache(); return true; //表示命令处理成功,不用继续其余的处理 } return false; //表示命令没有被处理,容许其余 ExecAction handlers继续处理 }
http://www.fiddlerbook.com/Fiddler/dev/IFiddlerExtension.aspcode