How can I convert oSession.Timers.ClientBeginRequest to unix time

0 Answers 19 Views
Fiddler Classic
Top achievements
Rank 1
Roger asked on 09 May 2022, 01:55 PM | edited on 09 May 2022, 05:07 PM

I like to grab the ClientBeginRequest and convert that to UNIX epoch time in the Fiddler scripts, however, I cant seem to get the known methods to work like Math.floor. 

var iat = oSession.Timers.ClientBeginRequest; -> this does not give me unix time in sec

The idea is to generate json data with iat, exp and convert it to base64 and add it to the header

        if (oSession.HostnameIs("") && oSession.uriContains("/value/"))
            // Take ClientBeginRequest and convert it to unix
            //    var iat = oSession.Timers.ClientBeginRequest;
            //    var iat2 = Math.floor(iat / 1000);
            // Take the // Take ClientBeginRequest and convert it to unix + 30 mins
            //    var minutesToAdd=30;
            //    var exp = new Date(iat + minutesToAdd*60000);

            // convert json data to base64
            //    var obj = {iat: 'iat', exp: 'exp'};
            //    objJsonStr = JSON.stringify(obj);
    //    objJsonB64 = Buffer.from(objJsonStr).toString("base64");

            //Add the value to header
            oSession.oRequest["new-header-name"] = "headerValue in base64";



I have iat and exp working, just need some help with converting the value to base64. 

        import Microsoft.JScript;

        var iat = Math.round((new Date()).getTime() / 1000);
        oSession.oRequest["iat"] = iat
        var exp = (iat + 1800);
        oSession.oRequest["exp"] = exp
        var data = {iat: 'iat', exp: 'exp'};


Nick Iliev
Telerik team
commented on 10 May 2022, 06:40 AM

Check the following threads for more information on how to handle JSON and Base64 in FIddlerScript



No answers yet. Maybe you can help?

Fiddler Classic
Asked by
Top achievements
Rank 1
Share this question