增加列
class Handlers
{
function BeginRequestTime(oS: Session)
{
if (oS.Timers != null)
{
return oS.Timers.ClientBeginRequest.ToString();
}
return String.Empty;
}
public static BindUIColumn("Time Taken")
function CalcTimingCol(oS: Session){
var sResult = String.Empty;
if ((oS.Timers.ServerDoneResponse > oS.Timers.ClientDoneRequest))
{
sResult = (oS.Timers.ServerDoneResponse - oS.Timers.ClientDoneRequest).ToString();
}
return sResult;
}
// 下面代码省略 把上面代码放在 class Handlers下即可
根据延迟时间设置颜色
static function OnBeforeResponse(oSession: Session) {
if (m_Hide304s && oSession.responseCode == 304) {
oSession["ui-hide"] = "true";
}
// 计算延迟时间开始
var t1_ms = oSession.Timers.ClientDoneRequest.ToUniversalTime().Millisecond;
var t1_m = oSession.Timers.ClientDoneRequest.ToUniversalTime().Minute;
var t1_s = oSession.Timers.ClientDoneRequest.ToUniversalTime().Second;
var t1 = t1_m*60*1000 + t1_s*1000 + t1_ms ;
var t2_ms = oSession.Timers.ServerDoneResponse.ToUniversalTime().Millisecond;
var t2_m = oSession.Timers.ServerDoneResponse.ToUniversalTime().Minute;
var t2_s = oSession.Timers.ServerDoneResponse.ToUniversalTime().Second;
var t2 = t2_m*60*1000 + t2_s*1000 + t2_ms ;
var diff = t2 - t1;
if (diff > 500){
oSession["ui-backcolor"] = "#7FFFD4";
}
// 计算延迟时间结束
//FiddlerObject.alert(t0)
//oSession["ui-backcolor"] = "#7FFFD4";
//oSession["ui-backcolor"] = "red";
}
Fiddler自动保存接口到文件
- 打开fiddler,配置抓取APP
- CTRL+R 进入 fiddler ScriptEdtor 文件中
- 搜索:OnBeforeRequest 或者OnBeforeResponse函数
- 插入代码块
if(oSession.HostnameIs("域名1")||oSession.HostnameIs("域名1")){
var filename = "D:/fiddler_url.txt";
var curDate = new Date();
var sw: System.IO.StreamWriter;
if (System.IO.File.Exists(filename)){
sw = System.IO.File.AppendText(filename);
sw.Write(oSession.url+'\n');
}
else{
sw = System.IO.File.CreateText(filename);
sw.Write(oSession.url+'\n');
}
sw.Close();
sw.Dispose();
}