Fiddler 在遵守时间的情况下请求 HTTP 请求

Fiddler to request HTTP requests with timing respected

是否可以使用 Fiddler 重放 HTTP 请求并遵守计算的会话计时?

我尝试用 fiddler 重放一个会话,但重放以最大速度发送请求而忽略了捕获时间。

我尝试将其添加到 onBeforeRequest() 函数中:

if (oSession.HostnameIs("example.com") && oSession.uriContains("page.html")) {
    // I tried this
    System.Threading.Thread.Sleep(1000);
    // and this
    // oSession["response-trickle-delay"] = "30"; 
}

但效果不是很好,我必须为每个捕获的 URI 重复此操作。

我需要重播捕获的会话,但发送请求的延迟必须与记录的延迟相同。可能吗?

Fiddler 本身不会尝试在重放请求时遵守相对时间。

您可以根据每个 Session 对象的 oTimers 数据编写脚本或扩展程序来执行此操作。

这是我的解决方案,可能对其他人有用:

static function DoTimedReplay() {
    var oSessions = FiddlerApplication.UI.GetSelectedSessions();
    if (oSessions.Length == 0) {
        oSessions = FiddlerApplication.UI.GetAllSessions();
        if (oSessions.Length == 0) {
            FiddlerObject.alert("No session available.");
            return;
        }
    }

    FiddlerObject.StatusText = "Start replay";
    var iStart = Environment.TickCount;
    for (var x:int = 0; x < oSessions.Length; x++) {
        var iDelay:Int32 = x == 0 ? 0 :
            System.Math.Round(
                (oSessions[x].Timers.ClientBeginRequest - oSessions[x - 1].Timers.ClientBeginRequest).TotalMilliseconds
            );
        replay(oSessions[x], iStart + iDelay);
    }
    FiddlerObject.StatusText = "Replay Done";
}

static function replay(oSession: Session, iDelay: Int32) {
        if (!String.IsNullOrEmpty(oSession["X-Replayed"]))
            return;
        try {
            var oSD = new System.Collections.Specialized.StringDictionary();
            oSD.Add("X-Replayed", "True");
            while (iDelay > Environment.TickCount) {
                Application.DoEvents();
            }
            FiddlerApplication.oProxy.SendRequest(oSession.oRequest.headers, oSession.requestBodyBytes, oSD);
        } catch(ex) {
            var iTickCount = Environment.TickCount + 10000;
            while (iTickCount > Environment.TickCount) {
                Application.DoEvents();
            }
        }
}

干杯