-3

Can HTTP request be replayed using Fiddler with caputered session timing respected?

I tried to replay a session with fiddler but the replay sends requests to the maximum speed ignoring the time of capture.

I tried to add this to onBeforeRequest() function:

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

but doesn't work very well and I must to repeat this for every captured URI.

I need to replay a captured session but the requests must be sent with the same delay as recorded. Is it possible?

Lucar
  • 3
  • 3

2 Answers2

1

Fiddler does not itself attempt to respect relative timings when replaying requests.

You could write script or an extension that would do so, based on each Session object's oTimers data.

EricLaw
  • 56,563
  • 7
  • 151
  • 196
0

here is my solution, it maybe useful to others:

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

Cheers

Lucar
  • 3
  • 3
  • Why does your catch block pump for 10 seconds? Your code presumes that the Sessions are sorted in order of ClientBeginRequest, which isn't always a safe assumption to make. – EricLaw Feb 11 '15 at 22:19