-3

是否可以使用 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 重复此操作。

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

4

2 回答 2

1

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

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

于 2015-01-29T08:37:51.220 回答
0

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

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();
            }
        }
}

干杯

于 2015-02-09T08:57:50.897 回答