Fiddler4监控请求时间与自定义过滤

打开Fiddler4,选择菜单【Rules】【Customize Rules...】,


找到下面代码:

,然后在下面添加如下代码,保存退出:

public static BindUIColumn("UseTime/ms" ,120)

function UseTime(oS: Session): String{

var sResult = "0";

var r1 = oS.Timers.ClientBeginRequest;

var r2 = oS.Timers.ClientDoneResponse;

var ts = r2.Subtract(r1).Milliseconds;

sResult = r1.Minute + ":" + r1.Second + "." + r1.Millisecond + " - " +

r2.Minute + ":" + r2.Second + "." + r2.Millisecond + " [" + ts +"]";

return sResult;

}


Capture监控栏目上就会出现UseTime/ms栏目,每一条请求会显示开始时间、结束时间和用时,对于优化网站比较有帮助。


Fiddler有个Filter过滤器UI,但是个性化的写代码更方便,如下示例:

//指定要监控的Host

static var MONITOR_HOST = "www.xxx.com";

static function OnPeekAtRequestHeaders(oSession: Session) {

if (MONITOR_HOST == null || MONITOR_HOST.length == 0)

return;

var host = oSession.host.toLowerCase();

var referer = ("" + oSession.RequestHeaders["Referer"]).toLowerCase();

if (!host.StartsWith(MONITOR_HOST) && !referer.StartsWith("http://" + MONITOR_HOST)) oSession["ui-hide"] = "NotMyApp";

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/11240.html