Search code examples
fiddlerextensibility

How to get the transfer time in a custom Fiddler inspector


I am writing a custom Fiddler inspector (inheriting from Inspector2 and implementing IResponseInspector2), and one of the things I want to show in the output of the inspector is the time it took for the response to come back from the server (relative to the time the corresponding request was sent from the client).

I basically want the user to see how long the request took without them having to switch to the Timeline view.

Does anyone know if there is a way to do this?


Solution

  • Ok - I found a way, but it seems sort of hacky - maybe there is a better way.

    Session[] sessions = FiddlerApplication.UI.GetSelectedSessions();
    if (sessions != null && sessions.Length == 1)
    {
        Session s = sessions[0];
        if (s != null && (s.state == SessionStates.Done))
        {
            TimeSpan totalTime = s.Timers.ClientDoneResponse - s.Timers.ClientBeginRequest;
            Debug.WriteLine("Time = " + totalTime.ToString());
        }
    }
    

    I guess I want a more elegant way to get the Session associated with the response that the inspector is currently processing.